0

I have a list containing a subset of index values from a large Pandas dataframe. I would like to use this list to select all columns with corresponding index values from the large df.

My solution now is to read the list containing the subset values as 2nd df with only an index column. I then use pd.index.intersection to select corresponding rows from the larger dataframe.

e.g. Large_dataframe[Large_dataframe.index.intersection(Index_col_only_df.index)]

This gives me the desired outcome but feels very clumsy.

I'm new to Pandas, so looking for the "correct" and more elegant way to do this, without having to convert the query list to an index-only dataframe.

Thanks for any suggestions!

JohanvH
  • 25
  • 4

0 Answers0