python 积累6

2019-01-04  本文已影响0人  黄yy家的jby

摘要

1.对dataframe列的运算

h7 = np.array(df) + np.array(df2)
h8 = np.array(df) * np.array(df2)
h5 = df.reset_index(drop = True) + df2.reset_index(drop=True)
h6 = df.reset_index(drop=True)*df2.reset_index(drop=True)
a = np.log(df.b)
b = df.a + df2.a
c = np.exp(df.a)

最终得到的a, b, c都是series

df['col3'] = df.apply(lambda x: x['col1'] + 2 * x['col2'], axis=1)
上一篇下一篇

猜你喜欢

热点阅读