Converting Numerical variable to Categorical in Python

import seaborn as sns
import pandas as pd
import numpy as np
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)df=pd.read_csv(C:/Users/ASUS/Desktop/titanic.csv)
#You also get the same dataset from seaborn
# df=sns.load_dataset('titanic').head(10)df.head()
df['New_Age']=pd.cut(df['Age'],[0,10,18,25,40,90])

--

--

--

a person who lives in 6b populated world.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Build your own JWT Authentication server with Node

Node.js Server + Docker + AWS EC2

Python Documentation

Stack vs Heap memory in Java

Honeypot Company Portrait Series: Mailbutler

StorexHub — an offline-first & open-source Zapier

O2 DEX x IM community AMA RECAP

Intro to ActiveRecord

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Muhammed Resit Cicekdag

Muhammed Resit Cicekdag

a person who lives in 6b populated world.

More from Medium

Interpreting Hostel Prices with Linear Regression

Ocean Scientist… Data Scientist… Ocean Data Scientist?

Things You Must Know Before Using Linear Regression | Part 2

Pandas for data analysis