0

I have this particular dataset in a CSV file, I want to find out the names of all crops that grow in the summer season. How can I do that?

enter image description here

  • 1
    Hello @Anvesh Mandlik, welcome to stackoverflow. What did you already try? Have you read this [how to ask page](https://stackoverflow.com/help/how-to-ask)? – ndclt Sep 16 '22 at 17:33
  • Does this answer your question? [How to filter Pandas dataframe using 'in' and 'not in' like in SQL](https://stackoverflow.com/questions/19960077/how-to-filter-pandas-dataframe-using-in-and-not-in-like-in-sql) – flaviut Sep 19 '22 at 20:13

1 Answers1

0

You can use pandas.DataFrame.loc to return the rows of every crop that grows in the summer.

import pandas as pd
df = pd.read_csv('anvesh.csv')

mask = df['Season']=='Summer'
out= df.loc[mask]

>>> display(out)

enter image description here

And if you need to get a list of all these crops, you can use this :

list(out['Crop'])
['Moong(Green Gram)'] #Output
Timeless
  • 22,580
  • 4
  • 12
  • 30