我的SQLite表中的某些单元格超出了终端中熊猫显示设置的长度。有没有办法使长信息换行到另一行?
这是我的代码:
def view_work(self, CID):
pd.set_option('display.max_columns', None)
sq="SELECT * FROM Work_Done WHERE CID=?;"
df=pd.read_sql_query(sq, self.conn, params=CID)
df=df.set_index("Date")
df=df.sort_values(by=['Date'])
return df
这是当前DataFrame的输出:
Date Work_Done Parts_Installed /
2018-12-20 Installed computer and removed all of the pre-...
2018-12-22 Worked on getting Antivirus instlaled. Set up ... None
我想要的是:
Date Work_Done Parts_Installed /
2018-12-20 Installed computer and removed all of the pre-
installed software. Joined computer to domain
and setup network applications for user.
2018-12-22 Worked on getting Antivirus installed. Set up a
printer/fax machine. Loaded software for user and
showed them how to use the computer. None
当“ Work_Done”单元超过最大显示长度时,是否可以自动换行?
答案 0 :(得分:0)
pd.set_option('display.max_colwidth', None)
应该为您完成这项工作。它将列宽设置为无限制而不会溢出(这意味着没有“...”但有自动换行符)。签入pandas docs。