Skip to content


Python tips

python, pandas1 min read

Last updated : 08/August/2020

Events are in reverse chronological order.

Drop duplicates, but ignore nulls

Here we have two sets of duplicates and as per the command we are keeping the last and eliminating the first.

General idea is NaNs are suppose to be incomparable as it basically means 'no value'. So, comparing no values and keeping the last does not make sense. So, we do this and here we are maintaining the uniqueness and keeping nulls

Convert two arrays to dictionary

View specific row by index

Read all columns into pandas as object

Common pandas options

Display all columns of specific datatype

If you have a column naming convention, like in column name itself we can identify datatype, you can use below method to get those columns. Here we are trying to get date columns,

Method 1

Method 2

Method 3