File size: 861 Bytes
2f0b408
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)