Check if string is in a pandas DataFrame
Example of any():
import pandas as pd df = pd.DataFrame({'DateOfBirth': ['1986-11-11', '1999-05-12', '1976-01-01', '1986-06-01', '1983-06-04', '1990-03-07', '1999-07-09'], 'State': ['NY', 'TX', 'FL', 'AL', 'AK', 'TX', 'TX'] }, index=['Jane', 'Pane', 'Aaron', 'Penelope', 'Frane', 'Christina', 'Cornelia']) if df['State'].str.contains('TX').any(): print("TX is there")
2018-11-18T17:35:11+05:30
2018-11-18T17:35:11+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution