4 回答
TA贡献1853条经验 获得超18个赞
一个简单的解决方案:
import pandas as pd
df = pd.read_csv(r"DataFrame_3x5.csv")
df['A'] - df['A'].median()
TA贡献1853条经验 获得超9个赞
我想如果你先尝试dropna然后简单地减去它就可以了
df=df.dropna(how='any')
df['Sub']=int(df['A']) - int(df['B']) - int(df['C'])
TA贡献1934条经验 获得超2个赞
import pandas as pd
data = pd.read_csv(r"DataFrame_3x5.csv")
df = pd.DataFrame(data)
medianList = pd.DataFrame()
for i in range(0, data.shape[1]):
medianList = medianList.append([df.iloc[:,i].median()], ignore_index=True)
df1 = pd.DataFrame(columns=['A'])
j=0
for i in range(0, data.shape[0]):
print(data['A'].iloc[i]) # one column
print(medianList.iloc[i]) #1 value
print(data['A'].iloc[i] - medianList.iloc[j])
添加回答
举报