Python Forum
Extracting Rows From Data Frame and Understanding The Code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extracting Rows From Data Frame and Understanding The Code
#1
Hello all

I have a data frame which i want to extract.

I am using the following code:-

Weekly_Report.iloc[:,0] == 75G2G2T8
I interpret this code as follows:-

From the selected data frame called Weekly Report.

I want all rows from the first column (which is indexed with 0) that equal 75G2G2T8

This gives me the following output:-
0 True
1 False
2 True
3 False
4 False

Where I have True then those rows equals my condition in that column.

This is where i need some help.

To get the actual rows of data that meet my condition i have been told to use the following code:-

Weekly_Report[Weekly_Report.iloc[:,0] == 75G2G2T8]
I dont understand why i need to put:-

Weekly_Report.iloc[:,0] == 75G2G2T8 
inside a set of square brackets with the name of the data frame Weekly_Report before it?

All i am doing, from my perspective, is passing in a list of True/False values and index numbers into the command:-

Weekly_Report[Index Values and True/False]
How does this extract the actual rows??

Can someone explain the code?

Can anyone help?

Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Algorithm for extracting comments from Python source code Pavel1982 6 412 Feb-28-2024, 09:52 PM
Last Post: Pavel1982
  how do you style data frame that has empty rows. gsaray101 0 498 Sep-08-2023, 05:20 PM
Last Post: gsaray101
  Code understanding: Need help in understanding dictionary code jt123 0 450 Jul-09-2023, 01:13 PM
Last Post: jt123
  New to python/coding Need help on Understanding why this code isn't working. Thanks! mat3372 8 1,662 May-09-2023, 08:47 AM
Last Post: buran
  googletrans library to translate text language for using data frame is not running gcozba2023 0 1,162 Mar-06-2023, 09:50 AM
Last Post: gcozba2023
  (Python) Pulling data from UA Google Analytics with more than 100k rows into csv. Stockers 0 1,170 Dec-19-2022, 11:11 PM
Last Post: Stockers
  Extracting Data into Columns using pdfplumber arvin 17 5,190 Dec-17-2022, 11:59 AM
Last Post: arvin
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 1,798 Dec-12-2022, 08:22 PM
Last Post: jh67
  Load multiple Jason data in one Data Frame vijays3 6 1,499 Aug-12-2022, 05:17 PM
Last Post: vijays3
  conditionals based on data frame mbrown009 1 873 Aug-12-2022, 08:18 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020