我试图在某个点包装文本,例如在单元格中的|
,并将其导出为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.split()
后跟explode()
。下面的代码应该会有所帮助输出结果如下
非常感谢你的帮助
我试着这样做。我相信有更好的代码
输出:
将其导出到html时,我得到以下信息:
Image 1: With Grid
是否有任何方式可以在没有网格的情况下导出它(可能有样式)
Image 2: Without Grid
让我们做吧
相关问题 更多 >
编程相关推荐