我是python的初学者,在我们的大学里他们分配了一个项目,即使用pandas python显示我们部门的时间表。我将我的程序呈现为菜单驱动程序。但问题是我无法在时间表中显示我的时间表在if else循环中使用head()的网格模式。你能让我知道我在哪里错了.. ?? 示例代码:
import pandas as pd
import numpy as np
loop=1
while loop==1:
print('WELCOME TO CBIT')
print('1.IT 2')
print('2.EXIT')
print()
choice=input('Enter ur choice')
choice=int(choice)
if choice==1:
df=input('tt is')
df=pd.read_excel('Book1.xlsx')
df.head()
elif choice==2:
loop=0
答案 0 :(得分:0)
pip install xlrd
我相信它会起作用。import pandas as pd
import numpy as np
loop=1
while loop==1:
print('WELCOME TO CBIT')
print('1.IT 2')
print('2.EXIT')
choice=int(raw_input('Input:'))
if choice==1:
#df=input('tt is')
df=pd.read_excel('filename.xlsx') #enter file name here
print(df)
#df.head()
elif choice==2:
loop=0
答案 1 :(得分:0)
添加打印声明:print(df.head())
。如果您正在寻找更好的显示器,可以查看pprint
。