先ほど質問させて頂いた者です。回答者様のアドバイスを受けて修正したところ、一部ですがこのようなエラーが出ました。これはどういったエラーなのでしょうか?対処法を教えて頂きたいです。
from google.colab import files
upload = files.upload()
from google.colab import files
upload = files.upload()
import pandas as pd
import numpy as np
import matplotlib.pyplot as plot
from sklearn.preprocessing import LabelEncoder
from sklearn.metrics import accuracy_score
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVC
train_set=pd.read_csv('train.csv')
test_set=pd.read_csv('test.csv')
train_set.head(2)
test_set.head(2)
fig=plot.figure(figsize=(12,4)) #figsize...ウィンドウの大きさ
ax1=fig.add_subplot(121) #ax...グラフ、add_subplot...グラフの場所指定
ax2=fig.add_subplot(122)
#PClass (旅客等級)
PClassPlot=train_set['Survived'].groupby(train_set['PClass']).mean()
ax1.bar(x=PClassPlot.index,height=PClassPlot.values)
ax1.set_ylabel('Survaival Rate')
ax1.set_xlabel('Gender')
ax1.set_xticks(GenderPlot.index)
ax1_set_yticks(np.arrenge(0,1.1,.1))
ax1.set_title("Class and Survival Rate")
↓以下エラー文
KeyError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2524 try:
-> 2525 return self._engine.get_loc(key)
2526 except KeyError:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'PClass'
During handling of the above exception, another exception occurred: