joyful pandas task

qq_41768189發表於2021-01-01

在這裡插入圖片描述
程式碼:
import pandas as pd
import numpy as np
df1 = pd.read_csv(‘company.csv’)
df2 = pd.read_csv(‘company_data.csv’)
income=df2.iloc[:,3]
income_sum=income.sum()
income_new=[x/income_sum for x in income]
I=[y*np.log(abs(y)) for y in income_new]
df1.insert(2,‘s’,I[:len(df1)])
-sum(I)
結果:
在這裡插入圖片描述
nan

相關文章