我是编程新手,我有一个关于python中pandas的问题,可能是noob,但在网上找不到答案
我编写了一段代码,使用python从pdf中提取数据
问题是熊猫是右对齐的,我的意思是第一列显示在右边,我如何修改它,使第一列默认显示在左边
import collections
import re
import pandas as pd
pdf = pdfplumber.open("1.pdf")
cost_page = pdf.pages[3]
text = cost_page.extract_text()
print(text)
all_pattern = re.compile(r'(\d{6}\-\d{4}) ([A-Z]\w*\D*) ([\w,]+[,]+\w+) (\w*)')
line_items = []
for line in text.split('\n'):
line = all_pattern.search(line)
if line:
Account_Code = line.group(1)
Description = line.group(2)
Actual_to_date = line.group(3)
Estimate_to_complete = line.group(4)
line_items.append(titles(Account_Code, Description, Actual_to_date, Estimate_to_complete))
如果要反转列的顺序,可以执行How to change the order of DataFrame columns?中的描述
相关问题 更多 >
编程相关推荐