Python:' unicode'对象没有属性'追加'同时使用熊猫

时间:2017-09-20 01:34:19

标签: python excel unicode

我有多张excel表。我想从一张纸上抓取两个单元格值并制作一张excel表。这是我的代码:

import pandas as pd
import numpy as np
import glob
import os
print glob.glob("C:/Users/admin/New folder/*.xlsx")
customer_name = pd.DataFrame()
customer_id= pd.DataFrame()
for f in glob.glob("C:/Users/admin/New folder/*.xlsx"):
    df = pd.read_excel(f,sheetname='Information')
    df1 = df.iloc[2,1]
    customer_name = customer_name.append(df1,ignore_index=True)
    df2 = df.iloc[2,2]
    customer_id = customer_name.append(df2,ignore_index=True)
result = customer_name.join(customer_id)
writer = pd.ExcelWriter('result.xlsx', engine='xlsxwriter')
result.to_excel(writer, sheet_name='Sheet1')
writer.save()

错误说:' unicode'对象没有属性'追加'

代码:customer_name = customer_name.append(df1,ignore_index = True)

我想在一张excel表中写df1和df2。它应该在excel表中看起来像这样:

John 1514

第5459号法案

如果有人可以提供帮助。我是python的新手并搜索了论坛但找不到解决方案。感谢。

0 个答案:

没有答案