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 a user-completed fillable pdf Perry 2 1,546 Sep-25-2025, 01:49 PM
Last Post: DeaD_EyE
  Extracting data from bank statement PDFs (Accountant) a4avinash 4 15,575 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 1,309 Dec-13-2024, 06:50 AM
Last Post: Gribouillis
  Algorithm for extracting comments from Python source code Pavel1982 7 5,163 Aug-28-2024, 02:50 AM
Last Post: timothyferriss
  Confused by the different ways of extracting data in DataFrame leea2024 1 1,312 Aug-17-2024, 01:34 PM
Last Post: deanhystad
  Extracting the correct data from a CSV file S2G 6 2,952 Jun-03-2024, 04:50 PM
Last Post: snippsat
  how do you style data frame that has empty rows. gsaray101 0 1,474 Sep-08-2023, 05:20 PM
Last Post: gsaray101
  Code understanding: Need help in understanding dictionary code jt123 0 1,201 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 4,554 May-09-2023, 08:47 AM
Last Post: buran
  googletrans library to translate text language for using data frame is not running gcozba2023 0 4,054 Mar-06-2023, 09:50 AM
Last Post: gcozba2023

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.