How to check if a python varaible is of type pandas.core.series.Series

Question:

In Python 3.x, how can I check if my variable is of type pandas.core.series.Series?

Asked By: JDoe

||

Answers:

You could use isinstance:

if isinstance(myvar, pandas.core.series.Series):
    # Do some processing
Answered By: Mureinik

Use isinstance:

s = pd.Series([2,3])

print (isinstance(s, pd.Series))
True
Answered By: jezrael
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.