mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-05-18 21:21:22 +00:00
Fix weekly seasonality plot in non-en locales
This commit is contained in:
parent
b7a201086d
commit
5cec062fce
2 changed files with 4 additions and 6 deletions
|
|
@ -951,11 +951,10 @@ prophet_plot_components <- function(m, fcst, uncertainty = TRUE) {
|
|||
}
|
||||
# Plot weekly seasonality, if present
|
||||
if ("weekly" %in% colnames(df)) {
|
||||
# Get weekday names in current locale
|
||||
days <- weekdays(seq.Date(as.Date('2017-01-01'), by='d', length.out=7))
|
||||
df.s <- df %>%
|
||||
dplyr::mutate(dow = factor(
|
||||
weekdays(ds), levels = c('Sunday', 'Monday', 'Tuesday', 'Wednesday',
|
||||
'Thursday', 'Friday', 'Saturday')
|
||||
)) %>%
|
||||
dplyr::mutate(dow = factor(weekdays(ds), levels = days)) %>%
|
||||
dplyr::group_by(dow) %>%
|
||||
dplyr::slice(1) %>%
|
||||
dplyr::ungroup() %>%
|
||||
|
|
|
|||
|
|
@ -695,8 +695,7 @@ class Prophet(object):
|
|||
df_s = fcst.copy()
|
||||
df_s['dow'] = df_s['ds'].dt.weekday_name
|
||||
df_s = df_s.groupby('dow').first()
|
||||
days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
|
||||
'Friday', 'Saturday']
|
||||
days = pd.date_range(start='2017-01-01', periods=7).weekday_name
|
||||
y_weekly = [df_s.loc[d]['weekly'] for d in days]
|
||||
y_weekly_l = [df_s.loc[d]['weekly_lower'] for d in days]
|
||||
y_weekly_u = [df_s.loc[d]['weekly_upper'] for d in days]
|
||||
|
|
|
|||
Loading…
Reference in a new issue