使用head()泛型函数创建python
我是python的初学者,在我们学院,他们分配了一个项目,即使用python显示我们系的时间表。我将我的程序呈现为菜单驱动程序。但问题是我无法使用if else循环中的head()以网格模式显示我的时间表。你能告诉我我错在哪里吗。。?? 示例代码:使用head()泛型函数创建python,python,pandas,head,Python,Pandas,Head,我是python的初学者,在我们学院,他们分配了一个项目,即使用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.E
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
使用此代码。它会起作用的。在使用此代码之前,请转到命令提示符并编写并执行此命令pip install xlrd
我确信它会工作。
添加打印语句:
print(df.head())
。如果你想找一个更好的显示器,你可以看一看。如果它解决了你的问题,那么接受答案并投票谢谢你,先生。但是我希望我的输出用边框线显示,先生。我得到的表格在单独使用head()时带有边框线。例如,使用代码:import pandas as pd import numpy as np df=pd.read\u excel('filename.xlsx)df.head()。但在菜单驱动程序中使用此代码时,我无法以网格模式获取输出。我获取输出,但没有任何行。pandas无法一次显示完整的数据帧
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