I am trying to extract the selected word & cross tab on a filtered dataset, using titantic dataset to illustrate.
train = pd.read_csv("d1.csv")
live= train[train['Survived']>0]# filter for survivors
print (live)
for live in live:
live['Tt'] = live.Name.str.extract(' ([A-Za-z]+)\.', expand=False)
pd.crosstab(live['Tt'], live['Sex'])
I received an error : AttributeError: 'str' object has no attribute 'Name'
Checked back to the filtered dataset live, the 'Name' variable is present in the dataset.
Which part did I go wrong and how do I extract answers that show survivors only with sex and tt in a cross tab?