Python Forum

Full Version: Combine a number into integer column and preserv format as number
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I have a DataFrame 150.000 rows x 56 columns.
I need change value in column MVA and put number 1 first any value

Before
MVA
38.24
33.29
25.08
31.37
29.02

After
MVA
1.3824
1.3329
1.2508
1.3137
1.2902
At the end I need this column with type number (int or float), because a I'll use for calculations.

I try this
df['MVA'] = df['MVA'].apply(lambda x: x*100)
But how insert number 1 front values?
You'll need to divide by 100 to move the decimal point and then add 1. This should do it.

df['MVA'] = df['MVA'].apply(lambda x: x / 100 + 1)
Hi stullis

my god, this is beautiful.

Thank you so much