Linked Questions

44 votes
2 answers
62k views

despite there being at least two good tutorials on how to index a DataFrame in Python's pandas library, I still can't work out an elegant way of SELECTing on more than one column. >>> d = pd....
LondonRob's user avatar
  • 79.8k
2 votes
5 answers
17k views

I am working in Pandas, and I want to apply multiple filters to a data frame across multiple fields. I am working with another, more complex data frame, but I am simplifying the contex for this ...
M. K. Hunter's user avatar
  • 1,868
0 votes
1 answer
227 views

I have a dataframe named df a b 0 str1 0 1 str2 .8 2 str3 .4 3 str4 .1 I am iterating through this dataframe. (which i know is not the most efficient way). I want to drop ...
johnnypython's user avatar
0 votes
0 answers
81 views

I want to retrieve rows which are not the indexes of a list of columns. Below is a df : I'm trying to extract rows of 'text' columns which are not state, gender. I tried the below to retrieve rows ...
Hackerds's user avatar
  • 1,205
0 votes
2 answers
5k views

Please help! I have tried different things/packages writing a program that takes in 4 inputs and returns the writing score statistics of a group based on those combination of inputs from a csv file. ...
Mikaz's user avatar
  • 3
3 votes
1 answer
3k views

I need to apply a single condition to 3 columns of a dataframe and change value of 4th without using or statement . I can do with np.where but if the no of columns is big it's going to take a lot ...
Sourav Roy's user avatar
1 vote
2 answers
3k views

How would I filter a dataframe using 'and' ? In other words, if I have a dataframe named m and it has columns a,b,c,d,e, how would i return all rows where the values in column b are greater than 120 ...
user3720101's user avatar
  • 1,505
1 vote
1 answer
1k views

After seeing this question about replicating SQL select-statement-like behavior in Pandas, I added this answer showing two ways that could shorten the verbose syntax given in the accepted answer to ...
ely's user avatar
  • 77.8k
3 votes
2 answers
2k views

Suppose I have a DataFrame like so, df = pd.DataFrame([['x', 1, 2], ['x', 1, 3], ['y', 2, 2]], columns=['a', 'b', 'c']) To select all rows where c == 2 and a == 'x', I could do ...
duckworthd's user avatar
  • 15.3k
2 votes
1 answer
566 views

NB: A question similar to this has been asked before but it doesn't exactly answer my question. How do I subset a pandas dataframe, with many columns, based on certain large number of columns ...
sntx's user avatar
  • 45