Spaces:
Sleeping
Sleeping
Download src/process_stream.py from Mayur-cinderace/investormlops-api: direct link, hf CLI and curl.
- Browser
- Download file 508 Bytes
-
https://huggingface.co/spaces/Mayur-cinderace/investormlops-api/resolve/main/src/process_stream.py
- Command line
-
hf download hf://spaces/Mayur-cinderace/investormlops-api/src/process_stream.py
-
curl -L -o process_stream.py https://huggingface.co/spaces/Mayur-cinderace/investormlops-api/resolve/main/src/process_stream.py
508 Bytes
| import pandas as pd | |
| from sentiment import compute_sentiment | |
| def process_stream(path="data/streaming/new_tweets.csv"): | |
| df = pd.read_csv(path) | |
| df["sentiment"] = df["text"].apply(compute_sentiment) | |
| # Aggregate daily sentiment | |
| daily = ( | |
| df.groupby(["date", "ticker"])["sentiment"] | |
| .mean() | |
| .reset_index() | |
| ) | |
| daily.to_csv("data/processed/new_sentiment.csv", index=False) | |
| print("Processed new sentiment data") | |
| if __name__ == "__main__": | |
| process_stream() | |