DataFrame slicing in Python

0 votes
How to extract a set of columns and rows from a large dataframe into a smaller dataframe. In this, I know the column headings, but the row numbers are not known, but I know the specific row contents to extract?
Jul 15, 2019 in Python by Firoz

1 answer to this question.

0 votes

You can use criteria based subset for example.

df[df.year == 2001]

In the above statement, it will subset the data where the year column has value 2001.

answered Jul 15, 2019 by Sakra

Related Questions In Python

+2 votes
6 answers

Slicing in Python

Index: ------------> ...READ MORE

answered Oct 18, 2018 in Python by abc
–1 vote
1 answer
0 votes
1 answer

Pandas dataframe with multiple lists in Python

You can do it like this import pandas ...READ MORE

answered Apr 6, 2019 in Python by Esha
0 votes
1 answer

Python Pandas Dataframe: set_value is deprecated and will be removed in a future release

The set_value function is deprecated and you will ...READ MORE

answered Apr 8, 2019 in Python by Jai
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,479 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

answered Nov 12, 2018 in Python by Nymeria
• 3,540 points
+1 vote
3 answers

How to change/update cell value in Python Pandas dataframe?

You can use the at() method to ...READ MORE

answered Apr 8, 2019 in Python by Kunal