Skip to content

Commit

Permalink
sunspots data url
Browse files Browse the repository at this point in the history
Signed-off-by: Giridhar Ganapavarapu <[email protected]>
  • Loading branch information
gganapavarapu committed Jun 20, 2023
1 parent 4deae42 commit 09c0bc9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions aix360/datasets/sunspots_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SunspotDataset:
New York: Springer-Verlag, 1985.
.. [#2] https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/sunspots.html
.. [#3] https://r-data.pmagunia.com/dataset/r-dataset-package-datasets-sunspots
.. [#4] https://github.com/PacktPublishing/Practical-Time-Series-Analysis/
"""

Expand All @@ -30,16 +31,17 @@ def __init__(self):
self.data_file = os.path.realpath(
os.path.join(self.data_folder, "sunspots.csv")
)
sunspots_url = (
"https://r-data.pmagunia.com/system/files/datasets/dataset-61024.csv"
)
sunspots_url = "https://raw.githubusercontent.com/PacktPublishing/Practical-Time-Series-Analysis/master/Data%20Files/monthly-sunspot-number-zurich-17.csv"

if not os.path.exists(self.data_file):
response = requests.get(sunspots_url)
data = pd.read_csv(StringIO(response.text))
data["time"] = pd.to_datetime(
data["time"].apply(self._convert_to_date), format="%Y-%m"
data = pd.read_csv(
StringIO(response.text),
skiprows=0,
nrows=2820,
)
data.columns = ["time", "sunspots"]
data["time"] = pd.to_datetime(data["time"], format="%Y-%m")

data.to_csv(self.data_file, index=False)

Expand Down

0 comments on commit 09c0bc9

Please sign in to comment.