I have a DataFrame say(df) in which columns are state , city , pincode.
I can select all the rows for particular city in a state like this.
requiredState = 'ABC'
requiredCity = 'XYZ'
newDf = df[ (df['city']== requiredCity) & (df['state']==requiredState) ]
Now I want to select all the rows for all cities of a state.
So this can be done by simply removing the city condition like:
newDf = df[ (df['state'] == requiredState) ]
This will give me all the cities of a state.
My question is, Is there some method in which I need not to remove the city condition and it will result to all the cities in a state?
i.e. something like
requiredCity = ALL
nDf = df[ (df['city']== requiredCity) & (df['state']==requiredState) ]
or Can we pass a list of required cities instead of ALL?
i.e.
requiredCity = ['city1','city2']