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

请教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日

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b