我有两个csv文件,每个文件都有一列。 该列在他们之间共享信息,如PassengerId,Name,Sex,Age。等
我正在尝试绘制每个标题(先生,夫人等)乘客分布年龄的图表框图。我收到一个错误。如何传递绘图可以绘制的错误?
import csv as csv
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
csv_file_object = csv.reader(open('test.csv', 'r'))
header = next(csv_file_object)
data=[]
for row in csv_file_object:
data.append(row)
data = np.array(data)
csv_file_object1 = csv.reader(open('train.csv', 'r'))
header1 = next(csv_file_object1)
data1=[]
for row in csv_file_object:
data1.append(row)
data1 = np.array(data1)
Mergerd_file = header.merge(header1, on='PassengerId')
df = pd.DataFrame(Mergerd_file, index=['pAge', 'Tilte'])
df.T.boxplot(vert=False)
plt.subplots_adjust(left=0.25)
plt.show()
我收到错误此错误
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-23-0d7fafc1fcf9> in <module>()
21
22
---> 23 Mergerd_file = header.merge(header1, on='PassengerId')
24
25 df = pd.DataFrame(Mergerd_file, index=['pAge', 'Tilte'])
AttributeError: 'list' object has no attribute 'merge'