Issue
I am sure there is an obvious way to do this but cant think of anything slick right now.
Basically instead of raising exception I would like to get True
or False
to see if a value exists in pandas df
index.
import pandas as pd
df = pd.DataFrame({'test':[1,2,3,4]}, index=['a','b','c','d'])
df.loc['g'] # (should give False)
What I have working now is the following
sum(df.index == 'g')
Solution
This should do the trick
'g' in df.index
Answered By - Guillaume Jacquenot
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.