Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

I would like to check in my Python 3.x if my variable is of type pandas.core.series.Series & if it's of pandas.core.series.Series type then I will do some processing. Can you please suggest me how to do it?

Thanks, Doe

like image 669
JDoe Avatar asked Jan 06 '18 10:01

JDoe


2 Answers

Use isinstance:

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

print (isinstance(s, pd.Series))
True
like image 177
jezrael Avatar answered Sep 27 '22 17:09

jezrael


You could use isinstance:

if isinstance(myvar, pandas.core.series.Series):
    # Do some processing
like image 44
Mureinik Avatar answered Sep 27 '22 17:09

Mureinik