Olivia姜元 2023-02-07 16:30 采纳率: 60%
浏览 90
已结题

请教FutureWarning:mad和save方法无效如何更改

‘’‘
FutureWarning1: The** 'mad' **method is deprecated and will be removed in a future version. To compute the same result, you may do (df - df.mean()).abs().mean().

FutureWarning2: save is not part of the public API, usage can give unexpected results and will be removed in a future version
xwf.save()
’‘’





import pandas as pd

import openpyxl as ol
import xlsxwriter as xl

import numpy as np

import seaborn as sns
import matplotlib.pyplot as plt

import statsmodels.api as sm


def status(x) :
    return pd.Series([x.count(),x.min(),x.idxmin(),x.quantile(.25),x.median(),x.quantile(.75),x.mean(),x.max(),x.idxmax(),x.mad(),x.var(),x.std(),x.skew(),x.kurt()],index=['总数','最小值','最小值位置','25%分位数', '中位数','75%分位数','均值','最大值','最大值位数','**平均绝对偏差**','方差','标准差','偏度','峰度'])
comcon=pd.read_excel('C:\\Users\\86135\\Desktop\\计量经济学\\课程数据库\\2comcon.xlsx')
y=comcon.comcon
x=comcon.avgdp
print(comcon)

df = pd.DataFrame(np.array([x,y]).T, columns=['x','y'])
print(df.apply(status))
wdata=df.apply(status)
xwf=pd.ExcelWriter('C:\\Users\\86135\\Desktop\\计量经济学\\课程数据库\\2comdescribe(每次运行要新的,记得换名称).xlsx', engine='xlsxwriter')
wdata.to_excel(xwf,sheet_name='data',index=True)
**xwf.save()**

sns.pairplot(comcon,x_vars='avgdp',y_vars='comcon',kind='reg')
plt.title('scatter')
plt.show()


x=sm.add_constant(x)
model=sm.OLS(y,x)
results=model.fit()
print(results.summary())
  • 写回答

2条回答 默认 最新

  • 元气少女缘结神 2023-02-07 16:56
    关注

    将save()改成close() !因为save已经不公开给用户使用了,你用close一样的它内部会调用内部的save。
    至于mad没看到你用啊,你没用怎么会有警告。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 2月15日
  • 已采纳回答 2月7日
  • 创建了问题 2月7日