# 熊猫-替换，浮动和列总和

``````import pandas as pd
import numpy as np

a=[['1','221,51','413,56','636,07'],['13','213','131.86','357,86'],['49','239.83','-238.83','10']]

df = pd.DataFrame(a)
repl_list = {',': '.'}
df.replace(repl_list, regex=True, inplace=True)

df[0] = df[0].astype(float)
df[1] = df[1].astype(float)
df[2] = df[2].astype(float)
df[3] = df[3].astype(float)

df['SUM'] = df.loc[df[0] >= 0, [0, 1, 2]].sum(axis=1)
df['SUM'] = df['SUM'].astype(float)
df['SUM'].fillna(0, inplace=True)
df['T/F'] = np.where((df['SUM'] >= df[3]), True, False)
a = df.loc[df['T/F'] == False]
print(df)
``````

``````      0       1       2       3     SUM    T/F
0   1.0  221.51  413.56  636.07  636.07  False
1  13.0  213.00  131.86  357.86  357.86   True
2  49.0  239.83 -238.83   10.00   50.00   True
``````

How does this float converter work? When I add to `a[]` values `['49','239.83','-288.83','10']` output looks like:

``````      0       1       2       3           SUM    T/F
0   1.0  221.51  413.56  636.07  6.360700e+02  False
1  13.0  213.00  131.86  357.86  3.578600e+02   True
2  49.0  239.83 -238.83   10.00  5.000000e+01   True
3  49.0  239.83 -288.83   10.00  5.684342e-14  False
``````