Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- city_country = {"Paris":"France", "Mexico":"Mexico", "Montreal":"Canada", "Moscow":"Russia", "Barcelona":"Spain", "Athens": "Greece"}
- sample["Host_Country"] = sample.City.map(city_country)
- mapper = {1:"First", 2:"Second", 3:"Third"}
- titanic.pclass = titanic.pclass.map(mapper)
- titanic["alone"] = pd.Series(np.where(titanic.no_relat == 0, "Yes", "No"))
- titanic["child"] = pd.Series(np.where(titanic.age < 18, "Yes", "No"))
- ############################################################################################
- # Creating Dummy Variables- from categorical to numeric data type
- titanic_d = pd.get_dummies(titanic, columns = ["sex", "pclass", "embarked", "age_cat"], drop_first=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement