Answers for "pandas astype int"

3

column dataframe to int

df[[column_name]].astype(int)
Posted by: Guest on April-21-2021
4

set column datatype pandas

df = pd.read_csv("weather.tsv", sep="\t",  
                 dtype={'Day': str,'Wind':int64})
df.dtypes
Posted by: Guest on October-14-2020
0

convert categorical data type to int in pandas

from sklearn import preprocessing

lab_encoder = preprocessing.LabelEncoder()
df['column'] = lab_encoder.fit_transform(df['column'])
Posted by: Guest on November-09-2021

Python Answers by Framework

Browse Popular Code Answers by Language