How to generate timeseries using Pandas and Seaborn?
PANDAS CHEATSHEET DATA CLEANING PYTHON DATA MUNGING MACHINE LEARNING RECIPES     ALL TAGS

How to generate timeseries using Pandas and Seaborn?

How to generate timeseries using Pandas and Seaborn?

This recipe helps you generate timeseries using Pandas and Seaborn

0
This data science python source code does the following: 1.Creating your own pandas series and timestams them. 2. Visualizes the series using seaborn libraries
In [2]:
## How to generate timeseries using Pandas and Seaborn
def Snippet_115():
    print()
    print(format('How to generate timeseries using Pandas and Seaborn','*^82'))

    import warnings
    warnings.filterwarnings("ignore")

    # load libraries
    import pandas as pd
    import matplotlib.pyplot as plt
    import seaborn as sns

    data = {'date': ['2014-05-01 18:47:05.069722', '2014-05-01 18:47:05.119994',
                     '2014-05-02 18:47:05.178768', '2014-05-02 18:47:05.230071',
                     '2014-05-02 18:47:05.230071', '2014-05-02 18:47:05.280592',
                     '2014-05-03 18:47:05.332662', '2014-05-03 18:47:05.385109',
                     '2014-05-04 18:47:05.436523', '2014-05-04 18:47:05.486877'],
        'deaths_regiment_1': [34, 43, 14, 15, 15, 14, 31, 25, 62, 41],
        'deaths_regiment_2': [52, 66, 78, 15, 15, 5, 25, 25, 86, 1],
        'deaths_regiment_3': [13, 73, 82, 58, 52, 87, 26, 5, 56, 75],
        'deaths_regiment_4': [44, 75, 26, 15, 15, 14, 54, 25, 24, 72],
        'deaths_regiment_5': [25, 24, 25, 15, 57, 68, 21, 27, 62, 5],
        'deaths_regiment_6': [84, 84, 26, 15, 15, 14, 26, 25, 62, 24],
        'deaths_regiment_7': [46, 57, 26, 15, 15, 14, 26, 25, 62, 41]}

    df = pd.DataFrame(data, columns = ['date', 'battle_deaths', 'deaths_regiment_1',
                'deaths_regiment_2', 'deaths_regiment_3', 'deaths_regiment_4',
                'deaths_regiment_5', 'deaths_regiment_6', 'deaths_regiment_7'])
    df = df.set_index(df.date)

    # dataFrame
    print(); print(df)

    # Time Series Plot
    sns.tsplot([df.deaths_regiment_1, df.deaths_regiment_2, df.deaths_regiment_3, df.deaths_regiment_4,
                df.deaths_regiment_5, df.deaths_regiment_6, df.deaths_regiment_7])
    plt.show()

Snippet_115()
***************How to generate timeseries using Pandas and Seaborn****************

                                                  date battle_deaths  \
date
2014-05-01 18:47:05.069722  2014-05-01 18:47:05.069722           NaN
2014-05-01 18:47:05.119994  2014-05-01 18:47:05.119994           NaN
2014-05-02 18:47:05.178768  2014-05-02 18:47:05.178768           NaN
2014-05-02 18:47:05.230071  2014-05-02 18:47:05.230071           NaN
2014-05-02 18:47:05.230071  2014-05-02 18:47:05.230071           NaN
2014-05-02 18:47:05.280592  2014-05-02 18:47:05.280592           NaN
2014-05-03 18:47:05.332662  2014-05-03 18:47:05.332662           NaN
2014-05-03 18:47:05.385109  2014-05-03 18:47:05.385109           NaN
2014-05-04 18:47:05.436523  2014-05-04 18:47:05.436523           NaN
2014-05-04 18:47:05.486877  2014-05-04 18:47:05.486877           NaN

                            deaths_regiment_1  deaths_regiment_2  \
date
2014-05-01 18:47:05.069722                 34                 52
2014-05-01 18:47:05.119994                 43                 66
2014-05-02 18:47:05.178768                 14                 78
2014-05-02 18:47:05.230071                 15                 15
2014-05-02 18:47:05.230071                 15                 15
2014-05-02 18:47:05.280592                 14                  5
2014-05-03 18:47:05.332662                 31                 25
2014-05-03 18:47:05.385109                 25                 25
2014-05-04 18:47:05.436523                 62                 86
2014-05-04 18:47:05.486877                 41                  1

                            deaths_regiment_3  deaths_regiment_4  \
date
2014-05-01 18:47:05.069722                 13                 44
2014-05-01 18:47:05.119994                 73                 75
2014-05-02 18:47:05.178768                 82                 26
2014-05-02 18:47:05.230071                 58                 15
2014-05-02 18:47:05.230071                 52                 15
2014-05-02 18:47:05.280592                 87                 14
2014-05-03 18:47:05.332662                 26                 54
2014-05-03 18:47:05.385109                  5                 25
2014-05-04 18:47:05.436523                 56                 24
2014-05-04 18:47:05.486877                 75                 72

                            deaths_regiment_5  deaths_regiment_6  \
date
2014-05-01 18:47:05.069722                 25                 84
2014-05-01 18:47:05.119994                 24                 84
2014-05-02 18:47:05.178768                 25                 26
2014-05-02 18:47:05.230071                 15                 15
2014-05-02 18:47:05.230071                 57                 15
2014-05-02 18:47:05.280592                 68                 14
2014-05-03 18:47:05.332662                 21                 26
2014-05-03 18:47:05.385109                 27                 25
2014-05-04 18:47:05.436523                 62                 62
2014-05-04 18:47:05.486877                  5                 24

                            deaths_regiment_7
date
2014-05-01 18:47:05.069722                 46
2014-05-01 18:47:05.119994                 57
2014-05-02 18:47:05.178768                 26
2014-05-02 18:47:05.230071                 15
2014-05-02 18:47:05.230071                 15
2014-05-02 18:47:05.280592                 14
2014-05-03 18:47:05.332662                 26
2014-05-03 18:47:05.385109                 25
2014-05-04 18:47:05.436523                 62
2014-05-04 18:47:05.486877                 41
In [ ]:

Relevant Projects

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.

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.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

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.

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.

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

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.

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.