erfanweb commited on
Commit
2f0b408
·
verified ·
1 Parent(s): fae4cc7

Create sentiment.py

Browse files
Files changed (1) hide show
  1. sentiment.py +21 -0
sentiment.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from transformers import pipeline
3
+
4
+ data = {
5
+ "timestamp": [
6
+ "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",
7
+ "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"
8
+ ],
9
+ "text": [
10
+ "Bitcoin is breaking resistance!", "Market looks weak today.", "Sideways action continues.", "ETH momentum is strong.", "Huge sell-off incoming?",
11
+ "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."
12
+ ]
13
+ }
14
+
15
+ df = pd.DataFrame(data)
16
+
17
+ classifier = pipeline('sentiment-analysis')
18
+
19
+ df['sentiment'] = df['text'].apply(lambda x: classifier(x)[0]['label'])
20
+
21
+ print(df)