Download sentiment.py from erfanweb/sentiment: direct link, hf CLI and curl.
- Browser
- Download file 861 Bytes
-
https://huggingface.co/erfanweb/sentiment/resolve/main/sentiment.py
- Command line
-
hf download hf://erfanweb/sentiment/sentiment.py
-
curl -L -o sentiment.py https://huggingface.co/erfanweb/sentiment/resolve/main/sentiment.py
861 Bytes
| import pandas as pd | |
| from transformers import pipeline | |
| data = { | |
| "timestamp": [ | |
| "2024-01-01 00:00:00", "2024-01-01 01:00:00", "2024-01-01 02:00:00", "2024-01-01 03:00:00", "2024-01-01 04:00:00", | |
| "2024-01-01 05:00:00", "2024-01-01 06:00:00", "2024-01-01 07:00:00", "2024-01-01 08:00:00", "2024-01-01 09:00:00" | |
| ], | |
| "text": [ | |
| "Bitcoin is breaking resistance!", "Market looks weak today.", "Sideways action continues.", "ETH momentum is strong.", "Huge sell-off incoming?", | |
| "Altcoins showing strong gains.", "Bearish trend might continue.", "Volume has been decreasing lately.", "Bitcoin hitting new all-time highs.", "Crypto market showing signs of recovery." | |
| ] | |
| } | |
| df = pd.DataFrame(data) | |
| classifier = pipeline('sentiment-analysis') | |
| df['sentiment'] = df['text'].apply(lambda x: classifier(x)[0]['label']) | |
| print(df) | |