【发布时间】:2020-08-12 07:40:23
【问题描述】:
我正在尝试在某个点换行文本,例如| 在单元格中并将其导出为 html。
一个例子:
import pandas as pd
df = pd.DataFrame({'EmployeeId': ['157', '292', '643', '124', '355'],
'City': ['Mumbai|Bangalore', 'Pune|Mumbai|Delhi', 'Mumbai|Bangalore', 'Mumbai|Pune', 'Bangalore']})
print(df)
df.to_html('test1.html')
输出:
EmployeeId City
0 157 Mumbai|Bangalore
1 292 Pune|Mumbai|Delhi
2 643 Mumbai|Bangalore
3 124 Mumbai|Pune
4 355 Bangalore
我会有一个这样的 html 文件(预期):
输出:
EmployeeId City
0 157 Mumbai
Bangalore
1 292 Pune
Mumbai
Delhi
2 ... ...
任何帮助将不胜感激。
【问题讨论】:
-
检查 str.contains
标签: python html string pandas dataframe