I have a pandas DataFrame
like this:
In [34]: people = pandas.DataFrame({\'name\' : [\'John\', \'John\', \'Mike\', \'Sarah\', \'Julie\'], \'age\
This should work:
people.set_index(people.columns.tolist(), drop=False).loc[filter].reset_index(drop=True)
# set_index with the columns you want to reference in tuples
cols = ['name', 'age']
people = people.set_index(cols, drop=False)
# ^
# |
# ensure the cols stay in dataframe
# does what you
# want but now has
# index that was
# not there
# /--------------\
people.loc[filter].reset_index(drop=True)
# \---------------------/
# Gets rid of that index