DEV Community

GharamElhendy
GharamElhendy

Posted on

Data Wrangling Techniques

To drop certain irrelevant columns when analyzing a dataset

df.drop(['ColumnX', 'ColumnY', 'ColumnZ'], axis=1, inplace=True)
Enter fullscreen mode Exit fullscreen mode

To count the number of values in a column

df['Column_name'].value_counts()
Enter fullscreen mode Exit fullscreen mode

To change the value to numeric

df['Column_name'] = pd.to_numeric(df['Column_name'])
Enter fullscreen mode Exit fullscreen mode

To replace certain values in a column to other values of choice

df['Column_name'] = df['Column_name'].replace(['Initial_value'], 'New_value')
Enter fullscreen mode Exit fullscreen mode

Top comments (0)