mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-11-18 08:53:42 +00:00
Clean non-ASCII characters out of generated_holidays
This commit is contained in:
parent
c9f1ccaa63
commit
a5da086ba0
4 changed files with 70675 additions and 67404 deletions
1
R/.Rbuildignore
Normal file
1
R/.Rbuildignore
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
^data-raw$
|
||||||
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
|
@ -10,12 +10,15 @@ from __future__ import division
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import inspect
|
||||||
|
import unicodedata
|
||||||
|
import warnings
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import warnings
|
|
||||||
import holidays as hdays_part1
|
import holidays as hdays_part1
|
||||||
import fbprophet.hdays as hdays_part2
|
import fbprophet.hdays as hdays_part2
|
||||||
import inspect
|
|
||||||
|
|
||||||
|
|
||||||
def generate_holidays_file():
|
def generate_holidays_file():
|
||||||
|
|
@ -54,7 +57,20 @@ def generate_holidays_file():
|
||||||
|
|
||||||
generated_holidays = pd.concat(all_holidays, axis=0, ignore_index=True)
|
generated_holidays = pd.concat(all_holidays, axis=0, ignore_index=True)
|
||||||
generated_holidays['year'] = generated_holidays.ds.apply(lambda x: x.year)
|
generated_holidays['year'] = generated_holidays.ds.apply(lambda x: x.year)
|
||||||
generated_holidays.to_csv("../R/data-raw/generated_holidays.csv")
|
generated_holidays.sort_values(['country', 'ds', 'holiday'], inplace=True)
|
||||||
|
|
||||||
|
# The holidays often have utf-8 characters.
|
||||||
|
# These are not allowed in R package data (they generate a NOTE).
|
||||||
|
# TODO: revisit whether we want to do this lossy conversion.
|
||||||
|
def utf8_to_ascii(text):
|
||||||
|
return (
|
||||||
|
unicodedata.normalize('NFD', text)
|
||||||
|
.encode('ascii', 'ignore')
|
||||||
|
.decode('ascii')
|
||||||
|
)
|
||||||
|
|
||||||
|
generated_holidays['holiday'] = generated_holidays['holiday'].apply(utf8_to_ascii)
|
||||||
|
generated_holidays.to_csv("../R/data-raw/generated_holidays.csv", index=False)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue