Skip to content

Latest commit

 

History

History
140 lines (68 loc) · 3.13 KB

plot_univariate_datetime_summary.rst

File metadata and controls

140 lines (68 loc) · 3.13 KB
.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_auto_examples_univariate_summaries_plot_univariate_datetime_summary.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

Univariate Datetime Summary

Example of univariate eda summary for a datetime variable. Here we look at posting times for TidyTuesday tweets.

The datetime summary computes the following:

  • A time seriesplot aggregated according to the ts_freq parameter
  • Barplots showing counts by day of week, month, hour of day, day of month
import pandas as pd
import plotly

import intedact

data = pd.read_csv(
    "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/tidytuesday_tweets/data.csv"
)
data["created_at"] = pd.to_datetime(data.created_at)
fig = intedact.datetime_summary(data, "created_at", fig_width=700)
plotly.io.show(fig)

By default, the summary tries to infer reasonable units for the time series. We can change these by using time unit strings for the ts_freq parameter.

fig = intedact.datetime_summary(data, "created_at", ts_freq="1 day", fig_width=700)
plotly.io.show(fig)

Example of changing plot type, removing trend line, and removing outliers.

fig = intedact.datetime_summary(
    data,
    "created_at",
    ts_type="markers",
    trend_line="none",
    upper_quantile=0.99,
    fig_width=700,
)
plotly.io.show(fig)
.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  4.192 seconds)


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: plot_univariate_datetime_summary.py <plot_univariate_datetime_summary.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: plot_univariate_datetime_summary.ipynb <plot_univariate_datetime_summary.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_