Data analysis with python and Pandas - Convert String Category to Numeric Values Tutorial 6

preview_player
Показать описание
Hi Guys checkout my udemy course at just 9.99$

Visit complete course on Data Science with Python :

For All other visit my udemy profile at :

This video will explain how to convert String categorical values to numerical values with apply function in pandas.

import pandas as pd

data = {'Id_Student' : [1,2,3,4,5,6,7,8,9,10],'Mathscore' :['Strong','Weak','Weak','Strong','Strong','Weak','Strong','Strong','Weak','Strong']}

df = pd.DataFrame(data)
df

# # Strong = 1 and Weak =0

def tran_mathscore(x):
if x == 'Strong':
return 1
if x == 'Weak':
return 0

df['Trans_MathScore'] = df['Mathscore'].apply(tran_mathscore)
df
Рекомендации по теме
Комментарии
Автор

Dude keep making such videos and just for your real hard work and no-filter attitude am subscribing to u. Keep posting and keep educating

ShubhamSingh-tunk
Автор

i want to change alphanumeric to numeric, for example in my column, there are values ID5001, ID5002, I want to write this as 5001, 5002. pls help

akashmanojchoudhary
Автор

Better to use

df['codes'] =

thetimeless
Автор

Hello, how we can convert Date into numericalvalue like 16Apr2018 to 43678 something number.

harishkvideos
Автор

a=int(input('enter a no'))
print (a)


It's giving an error...that invalid literal for int() with base 10: ' '

jyotikinkarsaharia
Автор

there are ways you can get this done in much lesser is nothing

AngelaOuyang
welcome to shbcf.ru