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

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

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.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

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.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

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

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

Human Activity Recognition Using Smartphones Data Set
In this deep learning project, you will build a classification system where to precisely identify human fitness activities.

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