Skip to content
Advertisement

Finding a specific string in a Dataframe column

I’m trying to retrieve one row of data from my Dataframe created from a csv file accessed via URL.

JavaScript

I’m using…

df1['Statistic Element'].str.contains('Mean rainfall')

…to determine the row containing the data I require however python does not recognize the .str element of the dataframe?

DF1.info()

The code works fine using a test dataframe so I’m wondering if there is a problem with the csv?

Advertisement

Answer

remove decode and StringIO and try again. here I have downloaded your ‘.csv’ file and renamed it “cs.csv”. nothing is wrong with it:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement