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
  Extracting data from bank statement PDFs (Accountant) a4avinash 4 5,773 Feb-27-2025, 01:53 PM
Last Post: griffinhenry
  Python: How to import data from txt, instead of running the data from the code? Melcu54 1 660 Dec-13-2024, 06:50 AM
Last Post: Gribouillis
  Algorithm for extracting comments from Python source code Pavel1982 7 2,966 Aug-28-2024, 02:50 AM
Last Post: timothyferriss
  Confused by the different ways of extracting data in DataFrame leea2024 1 704 Aug-17-2024, 01:34 PM
Last Post: deanhystad
  Extracting the correct data from a CSV file S2G 6 1,877 Jun-03-2024, 04:50 PM
Last Post: snippsat
  how do you style data frame that has empty rows. gsaray101 0 1,070 Sep-08-2023, 05:20 PM
Last Post: gsaray101
  Code understanding: Need help in understanding dictionary code jt123 0 948 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 3,538 May-09-2023, 08:47 AM
Last Post: buran
  googletrans library to translate text language for using data frame is not running gcozba2023 0 2,706 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,973 Dec-19-2022, 11:11 PM
Last Post: Stockers

Forum Jump:

User Panel Messages

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