what is the out put for df["column"].dtypes
- BENY
@kindall Oh so it's just operator precedence? I'll try df[~(df["column"].str.contains("Total"))]
- fredley
After some testing that doesn't seem to be the case, sorry for the red herring.
- kindall
1 Answers
95
votes
I think there are NaNs values, so need specify parameter na:
df = pd.DataFrame({
'column': ['Total','a',np.nan],
'B': list(range(3))
})
print (df)
column B
0 Total 0
1 a 1
2 NaN 2
df = df[~df["column"].str.contains("Total", na=False)]
print (df)
column B
1 a 1
2 NaN 2
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more
df[~(df["column"].str.contains("Total"))]- fredley