I have a pandas df where df['value'] is a series of floats.
df['is_it_whole'][i] with values 1 (or True) is the corresponding df['value'][i] is a whole number, 0 or False otherwise.df['is_it_whole'] = df['value'].is_integer() but pandas series do not support the is_integer method, I am looking for something similar that would work.Suggestions?
import pandas as pd
df = pd.DataFrame([['A', 1], ['B', 2.5], ['C', 3.0], ['D', 3.2]], columns=['label', 'value'])
df['is_it_whole'] = df['value'].map(lambda x: x.is_integer())
df
label value is_it_whole
0 A 1.0 True
1 B 2.5 False
2 C 3.0 True
3 D 3.2 False
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