0
点赞
收藏
分享

微信扫一扫

Pandas把Dataframe的前几行写入csv文件

无聊到学习 2022-04-14 阅读 123
python
import pandas as pd
df = pd.read_html("http://www.espn.com/nba/salaries/_/seasontype/4", encoding='utf-8',header=0)[0]
df1=df.iloc[0:10]
df1.to_csv('hi.csv', index=None)

前十行的实现 df1=df.iloc[0:10]

df1.to_csv('hi.csv', index=None),不要标题就header=None,不要行号就index=None

举报

相关推荐

0 条评论