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)