Skip to content

Commit 3c6f6a9

Browse files
committed
Add docstrings for functions in download_apple.py and task_datamanagement_apple.py.
1 parent 990ee4e commit 3c6f6a9

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

src/lennart_epp/data_management/download_apple.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@
66

77

88
def download_apple_data():
9+
"""Download and save historical Apple stock data.
10+
11+
Args:
12+
None
13+
14+
Returns:
15+
None
16+
17+
Raises:
18+
Exception: If the download fails due to network issues or API errors.
19+
"""
920
raw_data_path = SRC / "data" / "apple_data.csv"
1021

11-
# ✅ Nur herunterladen, wenn die Datei noch nicht existiert
1222
if not raw_data_path.exists():
1323
Path(raw_data_path.parent).mkdir(parents=True, exist_ok=True)
1424
apple_data = yf.download("AAPL", start="2013-01-01", end="2023-12-31")

src/lennart_epp/data_management/task_datamanagement_apple.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"""Tasks for managing the stock data."""
2-
31
import pandas as pd
42

53
from lennart_epp.config import BLD, SRC
@@ -11,7 +9,18 @@ def task_download_apple_data(
119
script=SRC / "data_management" / "download_apple.py",
1210
produces=SRC / "data" / "apple_data.csv",
1311
):
14-
"""Download AAPL stock data."""
12+
"""Download and save historical Apple stock data.
13+
14+
Args:
15+
script (Path, optional): Path to the script handling the download.
16+
produces (Path, optional): Path where the downloaded CSV file is stored.
17+
18+
Returns:
19+
None
20+
21+
Raises:
22+
AssertionError: If the file was not successfully created.
23+
"""
1524
download_apple_data()
1625
assert produces.exists(), f"Failed to produce {produces}"
1726

@@ -21,7 +30,19 @@ def task_clean_apple_data(
2130
data=SRC / "data" / "apple_data.csv",
2231
produces=BLD / "data" / "cleaned_apple_data.pkl",
2332
):
24-
"""Clean the stock data."""
33+
"""Load, clean, and store Apple stock data.
34+
35+
Args:
36+
script (Path, optional): Path to the script handling data cleaning.
37+
data (Path, optional): Path to the raw stock data CSV file.
38+
produces (Path, optional): Path where the cleaned data is stored.
39+
40+
Returns:
41+
None
42+
43+
Raises:
44+
AssertionError: If the cleaned data file was not successfully created.
45+
"""
2546
df = pd.read_csv(data, skiprows=2)
2647
df.columns = ["Date", "Close", "High", "Low", "Open", "Volume"]
2748
df = clean_apple_data(df)

0 commit comments

Comments
 (0)