已有184人关注
append被弃用了
发表在Python图书答疑 2022-04-16 《Python数据分析从入门到实践》第3章 Pandas入门
是否精华
版块置顶:

代码:

pandas pd

df = pd.DataFrame()
url_list = []
i ():
    url = % i
    url_list.append(url)
url url_list:
    df = df.append(pd.read_html(url)=)
df = df[[x.startswith() x df[]]]
(df)

报错:

FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)


分享到:
精彩评论 3
淡.印象
学分:323 LV5
TA的每日心情
学习Python
2020-11-23 22:17:24
2022-04-20
沙发

读者您好:

书中源码没有问题,请检查一下您的代码,代码中是否获取了网页地址,完整代码如下:

pandas pd
pd.set_option(, )
df=pd.DataFrame()
url_list=[]
i (1,14):
    url=+(i)
    url_list.append(url)
url url_list:
    df=df.append(pd.read_html(url),=)
(df)
df=df[[x.startswith() x df[3]]]
(df)
df.to_excel(,=[,,,],=)


2132067084
学分:10 LV2
2022-04-22
板凳

淡.印象 发表于2022-04-20 15:44

读者您好:

书中源码没有问题,请检查一下您的代码,代码中是否获取了网页地址,完整代码如下:

pandas pd
pd.set_option(, )
df=pd.DataFrame()
url_list=[]
i (1,14):
    url=+(i)
    url_list.append(url)
url url_list:
    df=df.append(pd.read_html(url),=)
(df)
df=df[[x.startswith() x df[3]]]
(df)
df.to_excel(,=[,,,],=)


D:\pycharm_Project_数据分析\venv\Scripts\python.exe D:/pycharm_Project_数据分析/pandas学习/dataframe对象/导入HTML文件.py

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

       0                    1                       2            3

1     41     Jaylen Brown, SG          Boston Celtics  $26,758,928

2     42    DeMar DeRozan, SF           Chicago Bulls  $26,000,000

3     43   Draymond Green, PF   Golden State Warriors  $24,026,712

4     44    Nikola Vucevic, C           Chicago Bulls  $24,000,000

5     45     John Collins, PF           Atlanta Hawks  $23,000,000

..   ...                  ...                     ...          ...

479  476  Ryan Arcidiacono, G         New York Knicks     $546,800

480  477  DeAndre' Bembry, SG         Milwaukee Bucks     $518,021

481  478     Goran Dragic, PG           Brooklyn Nets     $460,463

482  479     Jevon Carter, PG         Milwaukee Bucks     $441,277

483  480  Trendon Watford, PF  Portland Trail Blazers     $436,482


[440 rows x 4 columns]

D:\pycharm_Project_数据分析\pandas学习\dataframe对象\导入HTML文件.py:11: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

  df = df.append(pd.read_html(url),ignore_index=True)

这个返回结果中报错信息太多了


game99258
学分:2266 LV10
2022-07-05
地板

看那段代码,似乎没有写完

首页上一页 1 下一页尾页 3 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照