0

I have a dataframe df that looks like the following:

Type      Size
Biomass   12
Coal      15
Nuclear   23

And I have a string str such as the following: Biomass_wood I would like to return the following dataframe:

Type      Size
Biomass   12

This is because Biomass is partially matched by the first part of Biomass_wood.

This would effectively be the opposite of df[df.Type.str.contains(str)] as the bigger string is contained in str and not in the column Type

AKE
  • 101
  • 1
  • 8

1 Answers1

1

The following should do

df[df['Type'].map(lambda t: t in 'Biomass_wood')]
ayorgo
  • 2,163
  • 1
  • 21
  • 27