-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsplit_prices.py
More file actions
32 lines (24 loc) · 893 Bytes
/
split_prices.py
File metadata and controls
32 lines (24 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Split yfinance_prices.csv into separate files per ticker."""
import pandas as pd
from pathlib import Path
# Read the combined file
df = pd.read_csv('data/raw/yfinance_prices.csv')
print("=" * 80)
print("SPLITTING PRICE DATA BY TICKER")
print("=" * 80)
# Get unique tickers
tickers = df['ticker'].unique()
print(f"Found {len(tickers)} tickers: {', '.join(tickers)}\n")
# Split and save each ticker
for ticker in tickers:
ticker_df = df[df['ticker'] == ticker].copy()
output_path = Path(f"data/raw/yfinance_prices_{ticker}.csv")
ticker_df.to_csv(output_path, index=False)
print(f"✓ {ticker}: {len(ticker_df)} records → {output_path}")
print("\n" + "=" * 80)
print("✓ SPLIT COMPLETE")
print("=" * 80)
print("\nYou now have:")
for ticker in tickers:
print(f" - yfinance_prices_{ticker}.csv")
print(f" - yfinance_prices.csv (combined - all tickers)")