Questions tagged [time-series]

A Time series is a sequence of data points with values measured at successive times (either in continuous time or at discrete time periods). Time series analysis exploits this natural temporal ordering to extract meaning and trends from the underlying data.

Time series data is data with a pattern (“trend”) over time. Quantitative forecasting can be applied when two conditions are satisfied:

  1. numerical information about the past is available;
  2. it is reasonable to assume that some aspects of the past patterns will continue into the future.

Time series data are useful when you are forecasting something that is changing over time (e.g., stock prices, sales figures, profits, etc.). Examples of time series data include:

  • Daily IBM stock prices
  • Monthly rainfall
  • Quarterly sales results for Amazon
  • Annual Google profits

https://www.otexts.org/fpp/1/4

Time series models attempt to make use of the natural one-way ordering of time so that values for a given period will be expressed as a function of past values. This same idea is used in time series forecasting — future values based on past data.

Typically, time series data points are spaced at uniform time intervals.

A time series model will generally reflect the fact that observations close together in time will be more closely related than observations further apart.

As a place to start, take a look at Wikipedia's page on time series. For further reading, refer to the Statsoft website which has an online textbook on time series analysis.

For time series analysis in , consider looking at the Time Series Task View and questions tagged for the zoo package and for the xts package.


Tag usage:

Questions on tag should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis or Data Science, the StackExchange site for Data Science related topics like time series.

15192 questions
48
votes
3 answers

Return data subset time frames within another timeframes?

There are very nifty ways of subsetting xts objects. For example, one can get all the data for all years, months, days but being strictly between 9:30 AM and 4 PM by doing: my_xts["T09:30/T16:00"] Or you can get all the observations between two…
Alex
  • 19,533
  • 37
  • 126
  • 195
48
votes
2 answers

Annotate Time Series plot

I have an index array (x) of dates (datetime objects) and an array of actual values (y: bond prices). Doing the following: plot(x,y) produces a perfectly fine time series graph with the x-axis labeled with the dates. No problem so far. But I want…
luffe
  • 1,588
  • 3
  • 21
  • 32
48
votes
4 answers

How to resample a dataframe with different functions applied to each column?

I have a times series with temperature and radiation in a pandas dataframe. The time resolution is 1 minute in regular steps. import datetime import pandas as pd import numpy as np date_times = pd.date_range(datetime.datetime(2012, 4, 5, 8, 0), …
bmu
  • 35,119
  • 13
  • 91
  • 108
47
votes
1 answer

rolling joins data.table in R

I am trying to understand a little more about the way rolling joins work and am having some confusion, I was hoping somebody could clarify this for me. To take a concrete example: dt1 <- data.table(id=rep(1:5, 10), t=1:50, val1=1:50,…
Alex
  • 19,533
  • 37
  • 126
  • 195
46
votes
1 answer

Pandas compare next row

I have a dataframe like this d={} d['z']=['Q8','Q8','Q7','Q9','Q9'] d['t']=['10:30','10:31','10:38','10:40','10:41'] d['qty']=[20,20,9,12,12] I want compare first row with second row is qty same as next row AND is t greater in the next row AND is…
NinjaGaiden
  • 3,046
  • 6
  • 28
  • 49
44
votes
2 answers

How to properly add hours to a pandas.tseries.index.DatetimeIndex?

I have a normal df.index that I would like to add some hours to it. In [1]: test[1].index Out[2]: [2010-03-11, ..., 2014-08-14] Length: 52, Freq: None, Timezone: None This is how the first element looks…
hernanavella
  • 5,462
  • 8
  • 47
  • 84
43
votes
3 answers

Python & Pandas - Group by day and count for each day

I am new on pandas and for now i don't get how to arrange my time serie, take a look at it : date & time of connection 19/06/2017 12:39 19/06/2017 12:40 19/06/2017 13:11 20/06/2017 12:02 20/06/2017 12:04 21/06/2017 09:32 21/06/2017 18:23 21/06/2017…
Erwan Pesle
  • 821
  • 2
  • 8
  • 12
42
votes
13 answers

Basic lag in R vector/dataframe

Will most likely expose that I am new to R, but in SPSS, running lags is very easy. Obviously this is user error, but what I am missing? x <- sample(c(1:9), 10, replace = T) y <- lag(x, 1) ds <- cbind(x, y) ds Results in: x y [1,] 4 4 [2,]…
Btibert3
  • 38,798
  • 44
  • 129
  • 168
42
votes
3 answers

Apache Spark Moving Average

I have a huge file in HDFS having Time Series data points (Yahoo Stock prices). I want to find the moving average of the Time Series how do I go about writing the Apache Spark job to do that .
Ahmed Shabib
  • 687
  • 1
  • 8
  • 16
41
votes
5 answers

How to convert dataframe into time series?

I have one csv file in which I have 2 closing prices of stock(on daily basis) Dates Bajaj_close Hero_close 3/14/2013 1854.8 1669.1 3/15/2013 1850.3 1684.45 3/18/2013 1812.1 1690.5 3/19/2013 1835.9 1645.6 3/20/2013 1840 …
Neil
  • 7,937
  • 22
  • 87
  • 145
39
votes
4 answers

Extract date and time from pandas timestamp

I have a timestamp column where the timestamp is in the following format 2016-06-16T21:35:17.098+01:00 I want to extract date and time from it. I have done the following: import datetime as dt df['timestamp'] = df['timestamp'].apply(lambda x :…
chintan s
  • 6,170
  • 16
  • 53
  • 86
39
votes
6 answers

storing massive ordered time series data in bigtable derivatives

I am trying to figure out exactly what these new fangled data stores such as bigtable, hbase and cassandra really are. I work with massive amounts of stock market data, billions of rows of price/quote data that can add up to 100s of gigabytes every…
Shahbaz
  • 10,395
  • 21
  • 54
  • 83
37
votes
3 answers

Using JFreeChart to display recent changes in a time series

How can I use JFreeChart to display just the most recent data in a continually updated time series? Addenda: A complete, working example that incorporates the accepted answer is shown here. See also this variation having two series. See also this…
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
37
votes
3 answers

Counting frequency of values by date using pandas

Let's suppose I have following Time Series: Timestamp Category 2014-10-16 15:05:17 Facebook 2014-10-16 14:56:37 Vimeo 2014-10-16 14:25:16 Facebook 2014-10-16 14:15:32 Facebook 2014-10-16 13:41:01 Facebook 2014-10-16…
jcborges
  • 1,064
  • 2
  • 10
  • 13
37
votes
3 answers

R time series modeling on weekly data using ts() object

I am trying to do time series modeling and forecasting using R based on weekly data like below: biz week Amount Count 2006-12-27 973710.7 816570 2007-01-03 4503493.2 3223259 2007-01-10 2593355.9 1659136 2007-01-17 2897670.9…
user3281664
  • 371
  • 1
  • 3
  • 4