小编Van*_*nna的帖子

在pandas中分组和减去列

我有4列的时间序列数据,我想GROUPBY列FisherID,DateFishing并且Total_Catch,总结列Weight.此外,我想Total_catch在列重量中减去列中的值,其结果将保留在名为的新列中DIFF.而且,我想在列中DIFF显示高于的值0.1.

这是我的代码.

df["DIFF"]=df.groupby(["FisherID", "DateFishing", "Total_Catch"]) ["Weight"].sum()-["Total_Catch"]>=0.1
Run Code Online (Sandbox Code Playgroud)

我的数据:

FisherID    DateFishing Total_Catch Weight
1            24-Oct-11      0.9      0.2
1            24-Oct-11      0.9      0.264
1            24-Oct-11      0.9      0.37
2            25-Oct-11      0.7      0.144
2            27-Oct-11      8.2      0.084
2            27-Oct-11      8.2      0.45
3            27-Oct-11      8.2      0.61
3            27-Oct-11      8.2      7
3            29-Oct-11      0.64    0.184
Run Code Online (Sandbox Code Playgroud)

python group-by dataframe pandas pandas-groupby

4
推荐指数
1
解决办法
3618
查看次数

TypeError:inner()为关键字参数'ax'获取了多个值

我试着运行以下代码:

码:

df1=pd.read_excel('F:/MRCS_New_struture/2. EHM_Vanna/2015 Reports/Statistic_Env.xlsx', sheetname='Daitom (2)', header=0, index_col='Year')


CaAB=df1.iloc[:5,17:34]; print CaAB

a=[2007, 2008, 2011, 2013, 2015]
b=[100,200,300,500,22.33]

fig, ax=plt.subplots(2,1)

plt.plot(a, b, 'go-', label='line 1', linewidth=2, ax=ax)
plt.xticks(a, map(str,a))
CaAB.plot(kind='bar', ax=ax)
Run Code Online (Sandbox Code Playgroud)

并且,它生成了错误(TypeError:inner()获得了关键字参数'ax'的多个值).我的代码出了什么问题?

matplotlib

3
推荐指数
1
解决办法
7404
查看次数