Cleaning Data
Data we get from different sources may not be in the form or format for direct use in our applications. We need to correct these data by using various methods available in Pandas.
Removing comma from a string column
df['p_view']=df['p_view'].apply(lambda x: x.replace(',',''))
Converting to integer data type
df['p_view'] = df['p_view'].astype('int')
A regex which selects only characters in UTF-8, removing the rest, for each field in the dataframe.
df.replace({r'[^\x00-\x7F]+':''}, regex=True, inplace=True)
« Pandas
columns() add_prefix() add_suffix()
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com
Python programming Basics ⇩