I import some data from a parquet file into a DataFrame and want to check the data types. One of the data types I expect is strings. To do this, I have something like the following:
import pandas as pd
col = pd.Series([None, 'b', 'c', None, 'e'])
assert((col.dtype == object) and (isinstance(col[0], str)))
But, as you can see, this does not work if I accidentally have a None
value at the beginning.
Does anybody have an idea how to do that efficiently (preferably without having to check each element of the series)?