Pandas10——excel行列转换

excel转置
import pandas as pd

employee=pd.read_excel("D:\\python_pandas\\sample\\demo12\\Videos.xlsx",index_col="Month")
# table = employee.transpose()
table = employee.T
print(table.head())
打印结果:
Month         Jan   Feb   Mar    Apr  ...    Sep     Oct     Nov     Dec
Active User  1000  1500  2250   3375  ...  25635   38453   57680   86520
Page View    3500  5250  7875  11813  ...  89723  134586  201880  302820

DataFrame.T是DataFrame.transpose()的缩写

推荐视频链接
官方介绍

你可能感兴趣的:(Pandas10——excel行列转换)