In this blog we’ll discuss about few techniques while doing data analysis.

1. Check for null values

Once we read the dataset, we should always check for null values. Following line of code can be used for it:


It gives the total number of null values for each column in the dataset.

2. Check for duplicate values

We can check whether there are duplicate values in the dataset using the following command:


It gives us the total number of duplicated rows. We can drop using following command:


3. Check for unique values

It is useful for categorical data. Number of unique values can be checked in a particular column using following code:


4. Replace/Drop Null values

Dealing with null values is also very important for data analysis. We can either remove the column if there are too many null values


or we can impute them with mean/median/mode.


5. Correlation Matrix

It gives us the information about the correlation between different features. Following command can be used for it:

import seaborn as sns
corrmat = df.corr()
f, ax = plt.subplots(figsize=(12, 9))
sns.heatmap(corrmat, square=True);

We are using seaborn package to plot the matrix.

6. Check distribution of a variable

We can also check for the distribution of a particular column. By plot we can understand whether the data is following a normal distribution or some other. Following is the command:

import seaborn as sns

7. Check datatypes of columns

We can check the datatype of columns in the data. It helps us to confirm whether data is having correct data type or not.


8. Deal with datetime columns

Many times we get dates in a column but not in datetime format. We can convert it into one by using following code:

df["Date.of.Birth"] = df['Date.of.Birth'].astype('datetime64[ns]')

9. Value count

We can check the frequency of different categories in a categorical column:


10. Max/Min value of a column

We can find out the maximum and minimum values in a particular column using max() and min() command:

df['column'].max() df['column'].max()

You can checkout my sample notebook with all these commands in action with a dataset.

Jupyter Notebook

That’s it for now. Next time we’ll try to find out some more tips and tricks for data analysis. :)