我正在查看来自 Kaggle 比赛的著名泰坦尼克号数据集:http ://www.kaggle.com/c/titanic-gettingStarted/data
我已使用以下方法加载和处理数据:
# import required libraries
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
# load the data from the file
df = pd.read_csv('./data/train.csv')
# import the scatter_matrix functionality
from pandas.tools.plotting import scatter_matrix
# define colors list, to be used to plot survived either red (=0) or green (=1)
colors=['red','green']
# make a scatter plot
scatter_matrix(df,figsize=[20,20],marker='x',c=df.Survived.apply(lambda x:colors[x]))
df.info()
如何将 Sex 和 Embarked 等分类列添加到情节中?