【发布时间】:2021-05-07 11:11:30
【问题描述】:
我已经使用 tabula-py 命令从 pdf 中读取表格,代码如下:
table = tabula.read_pdf(files[0],pages = 'all',multiple_tables = True, stream = True)
有时来自两列的值会合并为一列(由单个空格分隔)。例如:
| col0 | col1 | col2 | col3 | col4 | col5 | col6 | col7 |
|---|---|---|---|---|---|---|---|
| a1 | b1 c1 | d1 | e1 f1 | g1 | h1 | NA | NA |
| a2 | b2 | c2 | d2 | e2 | f2 | g2 | h2 |
如何将值重新调整到正确的列中,以获得:
| col0 | col1 | col2 | col3 | col4 | col5 | col6 | col7 |
|---|---|---|---|---|---|---|---|
| a1 | b1 | c1 | d1 | e1 | f1 | g1 | h1 |
| a2 | b2 | c2 | d2 | e2 | f2 | g2 | h2 |
【问题讨论】:
标签: pandas dataframe split reshape