File size: 603 Bytes
726f5db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pandas as pd
import matplotlib.pyplot as plt

def read_data(file):
    try:
        if file.name.endswith(".csv"):
            data_frame = pd.read_csv(file)
        elif file.name.endswith(".xlsx"):
            data_frame = pd.read_excel(file)
        return data_frame
    except Exception as e:
        return f"Unable to read the file : {file}. Error : {e}"
    

def visualize_data(df,st):
    sentiment_counts = df['sentiment'].value_counts()
    fig, ax = plt.subplots()
    ax.pie(sentiment_counts, labels=sentiment_counts.index, autopct='%1.1f%%')
    ax.axis('equal')
    st.pyplot(fig)