0
假设我有一个像这个 -如何让熊猫数据框理解和评估一些表达式?
df = pd.DataFrame({'a': [1,2,3], 'b':[10,20,30], 'c':[8,9,10]})
here columns are -
c = ['a','b','c']
I can calculate different formulas like this -
df['sum'] = df[c].sum(axis=1)
df['avg'] = df[c].mean(axis=1)
列现在我有其中的公式都写在下面formats-
1. SUM(df[c])
2. AVG(df[c]) + MAX(df[c])
3. AVG(SUM(df[c])) * 100
etc..
Now is it possible to make above expressions being calculated by pandas without writing much logics in python code?