我的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‘单元格超出显示的最大长度时,可以对它们进行自动换行吗?
发布于 2021-02-08 22:06:13
pd.set_option('display.max_colwidth', None)应该为您做这项工作。它会将列宽设置为无限制,没有溢出(这意味着没有"...“但具有自动换行符)。检入pandas docs。
https://stackoverflow.com/questions/53938209
复制相似问题