1

I am following the tutorial http://ahmedbesbes.com/how-to-score-08134-in-titanic-kaggle-challenge.html and following is my code

from IPython.core.display import HTML
HTML("""
<style>
.output_png {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
}
</style>
""")

# remove warnings
import warnings
warnings.filterwarnings('ignore')
# ---

import pandas as pd
pd.options.display.max_columns = 100
import matplotlib

matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
matplotlib.style.use('ggplot')
import numpy as np

pd.options.display.max_rows = 100


data = pd.read_csv('./data/train.csv')

data.head()

data['Age'].fillna(data['Age'].median(), inplace=True)
survived_sex = data[data['Survived']==1]['Sex'].value_counts()
dead_sex = data[data['Survived']==0]['Sex'].value_counts()
df = pd.DataFrame([survived_sex,dead_sex])
df.index = ['Survived','Dead']
df.plot(kind='bar',stacked=True, figsize=(15,8))

I dont actually see the plot. How do i see the plot?

enter image description here

cchamberlain
  • 14,693
  • 6
  • 52
  • 67
raju
  • 4,752
  • 11
  • 56
  • 110

1 Answers1

1

Try using plt.show() at the end.

EDIT:

Also, you may need to add %matplotlib inline as explained here: How to make IPython notebook matplotlib plot inline

Community
  • 1
  • 1
denvaar
  • 1,988
  • 2
  • 17
  • 23