Handy Python functions for Data manipulation.

Pallavi Satsangi
4 min readNov 2, 2020

Listing down quick python functions that I use day in and out for data manipulation. Hope this is of help to folks working on the same.

After loading the sample csv file, the data is shown below

To print the column names

To find the number of rows and columns in a data frame

To know about the data

Describe the data

To see the sample of the data

To see the top 5 and last 5 records of the data frame

To remove spaces from the column names

To find the data type of a column

To convert the column values into String type

Alternatively

To find the unique values of a column

To find the size of the unique values in a particular column.

To remove the spaces from left side of the string

To remove the spaces from right side of the string

To remove spaces from both sides of the string

To drop NaN/null values from columns

To filter and get rows based on a column condition into a new or existing Data frame

To create a data frame other than the column conditions mentioned in the syntax

To create a data frame with selected columns

To replace a string value in a column

To drop duplicate values based on a column name

To group by a column name

To remove unicode characters from column values

To convert the data frame values to lower case

To merge two data frames based on a column

To find values based on a particular column value

To convert a “Date” column into a Date type object

To convert a column into String type

To Split a string in a column of a Data frame

To concatenate two columns into a new column in a data frame

To get the week day from a Date value present in a column

--

--

Pallavi Satsangi

Project Manager| Machine Learning |Data Science|Natural Language Processing|Neural Networks| MSc. Business Analytics