我的SQLite表的某些单元格超过了终端中pandas显示设置的长度。有没有一种方法可以使一个长的信息单元格自动换行到另一行?
下面是我的代码:
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”单元格超过最大显示长度时,是否可以自动换行?
1条答案
按热度按时间ttcibm8c1#
pd.set_option('display.max_colwidth', None)
应该为你做的工作。它会将列宽设置为无溢出(这意味着没有“...”,但有自动换行符)。检查pandas docs。