我正在研究分类问题并使用pandas库进行数据分析。使用pd.Dataframe()函数时,我收到上述错误。我是新手,并不理解这个错误的含义。以下是我的代码
`from scipy.misc import imread
import numpy as np
import os
import numpy as np
from sklearn.decomposition import RandomizedPCA
import pandas as pd
import pylab as pl
img_dir = 'pics/'
pics = [img_dir+ f for f in os.listdir(img_dir)]
def extrct_labels(filename):
n = len(filename)
y = np.zeros(n,dtype = np.int32)
for i,filename in enumerate(filename):
# If 'check' string is in file name assign '0'
if 'check' in str(filename):
y[i] = 0
else:
y[i] = 1
return y
data = []
for pic in pics:
img = imread(pic)
img = img.flatten()
data.append(img)
data = np.array(data)
pca = RandomizedPCA(n_components=2)
X = pca.fit_transform(data)
df = pd.DataFrame({"x-1": X[:,0], "x-2": X[:,1], "label": np.where(y==1, "Driver's License", "Check")})
`
感谢任何帮助。