I cannot make sense of below: When I check the type of "RUN_ID", it clearly states "float". But when I check if it is float, it returns False. What is this type exactly and how to check?
tags.loc[0, 'RUN_ID']
Out[36]: 38607.0
type(tags.loc[0, 'RUN_ID'])
Out[34]: float
isinstance(type(tags.loc[0, 'RUN_ID']),np.float64)
Out[32]: False
isinstance(type(tags.loc[0, 'RUN_ID']),np.float32)
Out[33]: False
isinstance(type(tags.loc[0, 'RUN_ID']),float)
Out[35]: False
You're using isinstance wrong. Instead of
isinstance(type(tags.loc[0, 'RUN_ID']),float)
just do
isinstance(tags.loc[0, 'RUN_ID'],float)
The type() function returns an object of type type, where you want the type of the object itself.
check with the regular float type instead of numpy. Test results below
w = isinstance(n, float) # True
x = isinstance(n, np.float32) # False
y = isinstance(n, np.float64) # False
z = type(n) == float # True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With