I'm programming a loop in which in each iteration the variable is either a series or an integer. I need to do different things in each case. How do I check the datatype and use it in a condition?
I've tried doing if(type(i)==) But it does not work
I'm programming a loop in which in each iteration the variable is either a series or an integer. I need to do different things in each case. How do I check the datatype and use it in a condition?
I've tried doing if(type(i)==) But it does not work
I think you need compare with pd.Series
:
i = pd.Series([1,2])
print (type(i) == pd.Series)
True
i = 5
print (type(i) == int)
True