time-series

pandas date to string

陌路散爱 提交于 2021-02-04 19:40:08
问题 i have a datetime pandas.Series . One column called "dates". I want to get 'i' element in loop like string. s.apply(lambda x: x.strftime('%Y.%m.%d')) or astype(str).tail(1).reset_index()['date'] or many other solutions don't work. I just want a string like '2016-09-16' (first datetime element in series) and not what is currently returned, which is: ss = series_of_dates.astype(str).tail(1).reset_index()['date'] "lol = %s" % ss lol = 0 2016-09-16\nName: date, dtype: object I need just: lol =

ARMA.predict for out-of sample forecast does not work with floating points?

让人想犯罪 __ 提交于 2021-02-01 04:59:20
问题 After i developed my little ARMAX-forecasting model for in-sample analysis i´d like to predict some data out of sample. The time series i use for forecasting calculation starts at 2013-01-01 and ends at 2013-12-31! Here is my data I am working with: hr = np.loadtxt("Data_2013_17.txt") index = date_range(start='2013-1-1', end='2013-12-31', freq='D') df = pd.DataFrame(hr, index=index) holidays = ['2013-1-1', '2013-3-29', '2013-4-1', '2013-5-1', '2013-5-9', '2013-5-20', '2013-10-3', '2013-12-25'

When using aTSA and Forecast Packages together forecast() function and Arima() gives error

感情迁移 提交于 2021-01-29 18:57:20
问题 I have been trying to use aTSA and Forecast package together and noticed that the Arima() function works but the forecast() give error. Does anyone have a solution for this or encountered this? I am especially trying to use stationary.test() from aTSA and that was the main reason I called the library. error: Error in forecast(.) : 'object' should be 'Arima' or 'estimate' class estimated from arima() or estimate() As soon as I removed aTSA, the above worked. fitArima_CO <- Arima(train_CO,

pandas time series: drop date from index

不想你离开。 提交于 2021-01-29 15:46:04
问题 I have a pandas DataFrame indexed by a DatetimeIndex that holds a time series, i.e. some data as a function of time. Now I would like to plot the behavior over the day regardless of the date. To do so I drop the date: for date, group in df.groupby(by = df.index.date): # drop date group.index = group.index.timetz However, like this I lose a lot of convenience functions of a DatetimeIndex , e.g. it is no longer possible to do things like df[df.index.hour > 9] Is there a better way to drop the

R: Plotting Multiple Confidence Intervals on the Same Graph

早过忘川 提交于 2021-01-29 15:14:09
问题 I am using the R programming language. I am trying to learn how to plot multiple time series on the same graph, as well as including their confidence intervals (in this case, their maximum and minimum values). Suppose I have two time series like this: library(xts) library(ggplot2) library(dplyr) library(plotly) library(lubridate) #time series 1 date_decision_made = seq(as.Date("2014/1/1"), as.Date("2016/1/1"),by="day") property_damages_in_dollars <- rnorm(731,100,10) final_data <- data.frame

Calculating time series days-in-a-row that fit certain criteria

五迷三道 提交于 2021-01-29 10:42:59
问题 I have a spatial and temporal df: 'date' 'spatial_pixel' 'column_A' ... ---- ----- --- 2012-04-01 | 1000 | 5 2012-04-01 | 1001 | 1 ... ... ... I want a column (groupedby 'spatial_pixel' and 'date') that counts the days-in-a-row a boolean is met. Say 'column_A' < 2: 'date' 'spatial_pixel' 'column_A' 'days-in-a-row' ... ---- ----- --- ---- 2012-03-30 | 1001 | 5 | 0 2012-04-01 | 1001 | 1 | 1 2012-04-02 | 1001 | 1 | 2 2012-04-03 | 1001 | 3 | 0 ... ... ... ... My Attempts: First, I made a new

Calculating average for certain time period in every year

我是研究僧i 提交于 2021-01-29 10:33:57
问题 I need to calculate seasonal averages for my data every year, the calculation of average is not in the same calendar year. I have defined season by date and am looking to calculate average temperature, precipitation etc for that time period every year (eg 12/21/1981 to 02/15/1982 , 12/21/1982 to 02/15/1983 ) and so on. Is there an efficient way of doing this in R? Below is my data: library(xts) seq <- timeBasedSeq('1981-01-01/1985-06-30') Data <- xts(1:length(seq),seq) Thanks 回答1: If we push

Deploy custom R script as web service Azure ML Studio

ⅰ亾dé卋堺 提交于 2021-01-29 09:51:02
问题 I have an R script which takes as input an excel file with two columns containing dates-values and it gives as output 3 dates with the corresponding prediction values. I have already successfully implemented it in Azure Machine Learning Studio using three nodes. One containing the zipped packages I use, one with the input .csv file and the last one with the R script. The problem is when I deploy it as a web service and I try to give as input new values for Col1 and Col2, I receive the

R: removing half of the confidence bands

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 08:56:51
问题 I am using the R programming language. I create the following data and graph: library(xts) library(ggplot2) library(dplyr) library(plotly) library(lubridate) set.seed(123) #time series 1 date_decision_made = seq(as.Date("2014/1/1"), as.Date("2016/1/1"),by="day") property_damages_in_dollars <- rnorm(731,100,10) final_data <- data.frame(date_decision_made, property_damages_in_dollars) #####aggregate final_data$year_month <- format(as.Date(final_data$date_decision_made), "%Y-%m") final_data$year

Counting consecutive values in rows in R

别来无恙 提交于 2021-01-29 08:56:37
问题 I have a time series and panel data data frame with a specific ID in the first column, and a weekly status for employment: Unemployed (1), employed (0). I have 261 variables (the weeks every year) and 1.000.000 observations. I would like to count the maximum number of times '1' occurs consecutively for every row in R. I have looked a bit at rowSums and rle(), but I am not as far as I know interested in the sum of the row, as it is very important the values are consecutive. You can see an