text_html_output_1.png text_plain_output_1.png
import pandas as pd

TitanicPath = '../input/titanic-data/train.csv'

import pandas as pd
Titanic = pd.read_csv(TitanicPath)

Columns = pd.DataFrame({'Nombre': Titanic.columns, 'Tipo': [str(type(c)) for c in Titanic.columns]})
Columns[:]

Titanic[Titanic.PassengerId == 148]

FirstClass = Titanic[Titanic.Pclass == 1].Name

Titanic['NoUnderAge'] = Titanic.Age >= 18
Titanic[:]

Titanic[Titanic.Fare == Titanic.Fare.max()]

Titanic[Titanic.Fare == Titanic.Fare.min()]

f = open('titanic.json', 'w')
f.write(Titanic.to_json())
f.close()

TitanicSurvived = Titanic[Titanic.Survived == 1]
TitanicDied = Titanic[Titanic.Survived == 0]
TitanicSurvivedMalesCount = TitanicSurvived[TitanicSurvived.Sex == 'male'].Sex.count()
TitanicSurvivedFemalesCount = TitanicSurvived[TitanicSurvived.Sex == 'female'].Sex.count()
TitanicSurvivedNoUnderAgeCount = TitanicSurvived[TitanicSurvived.NoUnderAge == True].NoUnderAge.count()
TitanicSurvivedUnderAgeCount = TitanicSurvived[TitanicSurvived.NoUnderAge == False].NoUnderAge.count()
print(f'1 - La clase de pasajero media fue mas alta en los sobrevivientes {TitanicSurvived.Pclass.median()} que del resto {TitanicDied.Pclass.median()}')
print(f'2 - El precio del tiquete medio fue mas alto en los sobrevivientes {TitanicSurvived.Fare.median()} que del resto {TitanicDied.Fare.median()}')
print(f'3 - Sobrevivieron mas mujeres {TitanicSurvivedFemalesCount} que hombres {TitanicSurvivedMalesCount}')
print(f'4 - Sobrevivieron mas mayores de edad {TitanicSurvivedNoUnderAgeCount} que menores de edad {TitanicSurvivedUnderAgeCount}')
TitanicSurvived[:]