Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert categorical data type to int in pandas

from sklearn import preprocessing

lab_encoder = preprocessing.LabelEncoder()
df['column'] = lab_encoder.fit_transform(df['column'])
Comment

panda categorical data into numerica

sex = train_dataset['Sex'].replace(['female','male'],[0,1])
print(sex)
Comment

pandas categorical to numeric

#this will label as one hot vectors (origin is split into 3 columns - USA, Europe, Japan and any one place will be 1 while the others are 0)
dataset['Origin'] = dataset['Origin'].map({1: 'USA', 2: 'Europe', 3: 'Japan'})
Comment

PREVIOUS NEXT
Code Example
Python :: random forest cross validation python 
Python :: find nan values in a column pandas 
Python :: how to get width of an object in pyqt5 
Python :: python keyboard press 
Python :: python iterate over object fields 
Python :: how to save array python 
Python :: command prompt pause in python 
Python :: export csv from dataframe python 
Python :: numpy correlation 
Python :: forbidden (csrf cookie not set.) django rest framework 
Python :: scikit learn split data set 
Python :: MySQLdb/_mysql.c:46:10: fatal error: Python.h: No such file or directory 
Python :: python overwrite print on same line 
Python :: python sorting array without inbuilt sort 
Python :: how to subtract dates in python 
Python :: discord embed colors python 
Python :: ready command discord.py 
Python :: how to check if everything inside a list is unique 
Python :: python open folder in explorer 
Python :: remove last element from dictionary python 
Python :: how to find duplicate numbers in list in python 
Python :: python link to jpg 
Python :: TypeError: dict is not a sequence 
Python :: enumerate in python 
Python :: requests session in python 
Python :: python set a specific datetime 
Python :: add something to list python 
Python :: python get lan ip 
Python :: python get nth letter of alphabet 
Python :: max of matrix numpy 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =