How to calculate difference between Dates in Python?
DATA MUNGING

How to calculate difference between Dates in Python?

How to calculate difference between Dates in Python?

This recipe helps you calculate difference between Dates in Python

0
In [1]:
## How to claculate difference between Dates in Python 
def Kickstarter_Example_42():
    print()
    print(format('How to claculate difference between Dates in Python',
                 '*^82'))
    import warnings
    warnings.filterwarnings("ignore")

    # Load library
    import pandas as pd

    # Create data frame
    df = pd.DataFrame()

    # Create two datetime features
    df['Date1'] = [pd.Timestamp('01-01-2017'),
                     pd.Timestamp('01-04-2017')]
    df['Date2']    = [pd.Timestamp('01-01-2017'),
                     pd.Timestamp('01-06-2017')]

    # Calculate Difference (Method 1)
    print(df['Date2'] - df['Date1'])

    # Calculate Difference (Method 2)
    print(pd.Series(delta.days for delta in (df['Date2'] - df['Date1'])))

Kickstarter_Example_42()
***************How to claculate difference between Dates in Python****************
0   0 days
1   2 days
dtype: timedelta64[ns]
0    0
1    2
dtype: int64

Relevant Projects

Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Predict Census Income using Deep Learning Models
In this project, we are going to work on Deep Learning using H2O to predict Census income.

Choosing the right Time Series Forecasting Methods
There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.