0

How can I search for a substring within a column of a csv file, for example in the file column I want to select the rows where the word "fog" is found, but there are rows where there are the words "rain, cold, fog" and also I want those rows to appear.

I was using the following code:

 df = pd.read_csv('weather_2012.csv')
 neblina = df[df['Weather'] == 'Fog']

But using that instruction the rows of the form "rain, cold, fog" are not shown, how can I do to show the rows of that style

Beforehand thank you very much

1 Answers1

1

Or you can use that

 df = pd.read_csv('weather_2012.csv')
 neblina = df[ 'Fog' in df['Weather']]
Bahae El Hmimdi
  • 364
  • 1
  • 5