Reputation: 1
import pandas as pd
import numpy as np
df1=pd.read_csv('train.csv')
df1=df1.drop("Cabin",axis=1)
df1['Embarked'].fillna(method='ffill',inplace=True)
df1['Age'].fillna(value=df1['Age'].mean(),inplace=True)
pd.pivot_table(df1, index=['Survived'], values=['Age'], aggfunc='std', margins=True)
I was writing a ML code, Survived was int and Age was float, but there was no any respond after I ran the code.
In reference book, it will should show me an analysis form, but this code didn't.
Upvotes: 0
Views: 66
Reputation: 2484
If you are working on IDE, not Jupyter Notebook, the code does not show any result.
You can create a new dataframe and see the pivoted result as follows:
df2 = pd.pivot_table(df1, index=['Survived'], values=['Age'], aggfunc='std', margins=True)
print(df2)
If you just want to see the result without assigning the pivoted dataframe:
print(pd.pivot_table(df1, index=['Survived'], values=['Age'], aggfunc='std', margins=True))
Many examples assume that you are working on Jupyter Notebook, which shows/prints variables without print
function.
Upvotes: 2