Feature Engineering
Feature Engineering helps to derive some valuable features from the existing ones. These extra features sometimes help in increasing the performance of the model significantly and certainly help to gain deeper insights into the data.
Python3
splitted = df[ 'Origin Time' ]. str .split( ' ' , n = 1 , expand = True ) df[ 'Date' ] = splitted[ 0 ] df[ 'Time' ] = splitted[ 1 ]. str [: - 4 ] df.drop( 'Origin Time' , axis = 1 , inplace = True ) df.head() |
Output:
Now, let’s divide the date column into the day, month, and year columns respectively.
Python3
splitted = df[ 'Date' ]. str .split( '-' , expand = True ) df[ 'day' ] = splitted[ 2 ].astype( 'int' ) df[ 'month' ] = splitted[ 1 ].astype( 'int' ) df[ 'year' ] = splitted[ 0 ].astype( 'int' ) df.drop( 'Date' , axis = 1 , inplace = True ) df.head() |
Output:
Analyze and Visualize Earthquake Data in Python with Matplotlib
Earthquake is a natural phenomenon whose occurrence predictability is still a hot topic in academia. This is because of the destructive power it holds. In this article, we’ll learn how to analyze and visualize earthquake data with Python and Matplotlib.