How to deal with Date & Time Basics in Python?
DATA MUNGING DATA CLEANING PYTHON MACHINE LEARNING RECIPES PANDAS CHEATSHEET     ALL TAGS

How to deal with Date & Time Basics in Python?

How to deal with Date & Time Basics in Python?

This recipe helps you deal with Date & Time Basics in Python

0
This data science python tutorial does the following: 1. Imports the necessary libraries for date-time manipulation. 2. Filters out date, month and year using functions. 3. Use of delta function in context of timeseries. 4. Arithmetic transformation on timestamped data.
In [1]:
## How to deal with Date & Time Basics in Python
def Kickstarter_Example_55():
    print()
    print(format('How to deal with Date & Time Basics in Python','*^82'))
    import warnings
    warnings.filterwarnings("ignore")

    # Load Libraries
    from datetime import datetime
    from datetime import timedelta
    # Create a variable with the current time
    now = datetime.now()
    print(); print(now)
    # The current year
    print(); print(now.year)
    # The current month
    print(); print(now.month)
    # The current day
    print(); print(now.day)
    # The current hour
    print(); print(now.hour)
    # The current minute
    print(); print(now.minute)
    # The difference between two dates
    delta = datetime(2011, 1, 7) - datetime(2011, 1, 6)
    print(); print(delta)
    # The difference days
    print(); print(delta.days)
    # The difference seconds
    print(); print(delta.seconds)
    # Create a time
    start = datetime(2018, 1, 7)
    # Add twelve days to the time
    print(); print(start + timedelta(12))

Kickstarter_Example_55()
******************How to deal with Date & Time Basics in Python*******************

2019-04-19 11:23:33.895987

2019

4

19

11

23

1 day, 0:00:00

1

0

2018-01-19 00:00:00

Relevant Projects

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

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.

Solving Multiple Classification use cases Using H2O
In this project, we are going to talk about H2O and functionality in terms of building Machine Learning models.

Machine Learning or Predictive Models in IoT - Energy Prediction Use Case
In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

Sequence Classification with LSTM RNN in Python with Keras
In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset​ using Keras in Python.

Data Science Project - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

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