print dataframe时的参数控制,index和列间隔。直接看代码~
import pandas as pd
pd.__version__
'1.1.5'
df = pd.DataFrame({"id":[1,2,3],"name":["jordan","kobe","duncan"],"team":["Bulls","Lakers","Spurs"]})
print(df)
id name team
0 1 jordan Bulls
1 2 kobe Lakers
2 3 duncan Spurs
去掉index
print(df.to_string(index=False))
id name team
1 jordan Bulls
2 kobe Lakers
3 duncan Spurs
print(df.to_string(index=False,col_space=10))
id name team
1 jordan Bulls
2 kobe Lakers
3 duncan Spurs
2021-06-08 于南京市江宁区九龙湖