# Time Series Data Analysis In Python

## A practical guide for time series data analysis in Python Pandas

Time series data is one of the most common data types in the industry and you will probably be working with it in your career. Therefore understanding how to work with it and how to apply analytical and forecasting techniques are critical for every aspiring data scientist. In this series of articles, I will go through the basic techniques to work with time-series data, starting with data manipulation, analysis, and visualization to understand your data and prepare it for and then using statistical techniques, machine, and deep learning techniques for forecasting and classification. It will be more of a practical guide in which I will be applying each discussed and explained concept to real data.

This series will consist of 10 articles:

- Manipulating Time Series Data In Python Pandas [A Practical Guide]
- Time Series Analysis in Python Pandas [A Practical Guide] (You are here)
- Visualizing Time Series Data in Python [A practical Guide]
- Time Series Forecasting with ARIMA Models In Python [Part 1]
- Time Series Forecasting with ARIMA Models In Python [Part 2]
- Machine Learning for Time Series Data [Regression]
- Machine Learning for Time Series Data [Classifcation] (Comming soon)
- Deep Learning for Time Series Data [A practical Guide](Comming soon)
- Time Series Forecasting project using statistical analysis, machine learning & deep learning (Comming soon)
- Time Series Classification using statistical analysis, machine learning & deep learning (Comming soon)

# Table of content:

- Correlation and Autocorrelation
- Time Series Models
- Autoregressive (AR) Models
- Moving Average (MA) and ARMA Models
- Case Study: Climate Change

**All the codes and datasets used in this article can be found in this repository.**

**If you want to study Data Science and Machine Learning for free, check out these resources:**

- Free interactive roadmaps to learn Data Science and Machine Learning by yourself. Start here: https://aigents.co/learn/roadmaps/intro
- The search engine for Data Science learning resources (FREE). Bookmark your favorite resources, mark articles as complete and add study notes. https://aigents.co/learn
- Want to learn Data Science from scratch with the support of a mentor and a learning community? Join this Study Circle for free: https://community.aigents.co/spaces/9010170/

**If you would like to start a career in data science & AI and you do not know how. I offer data science mentoring sessions and long-term career mentoring:**

- Long-term mentoring: https://lnkd.in/dtdUYBrM
- Mentoring sessions: https://lnkd.in/dXeg3KPW

*Join the Medium membership program for only 5 $ to continue learning without limits. I’ll receive a small portion of your membership fee if you use the following link, at no extra cost to you.*

# 1. Correlation and Autocorrelation

In this section, you’ll be introduced to the ideas of correlation and autocorrelation for time series. Correlation describes the relationship between two-time series and autocorrelation describes the relationship of a time series with its past values.

## 1.1. Correlation of Two Time Series

The correlation of the two-time series measures how they vary with each other. The correlation coefficient summarizes this relation in one number. A correlation of one means that the two series have a perfect linear relationship with no deviations. High correlations mean that the two series strongly vary together. A low correlation means they vary together, but there is a weak association. And a high negative correlation means they vary in opposite directions, but still with a linear relationship.

There is a common mistake when calculating the correlation between two trending time series. Consider two-time series that are both trending. Even if the two series are totally unrelated, you could still get a very high correlation. That’s why, when you look at the correlation of say, two stocks, you should look at the correlation of their **returns**, not their **levels**.

In the example below, the two series, **stock prices, and UFO sightings**, both trend up over time. Of course, there is no relationship between those two series, but the correlation is 0.94. But if you compute the correlation of percent changes, the correlation goes down to approximately zero.