-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
124 lines (104 loc) · 4.68 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import plotly.express as px
import seaborn as sns
import plotly.graph_objects as go
# categorical Data = ['Out/Not Out', 'Against', 'Venue', 'Column1', 'H/A', 'Date', 'Result','Format', 'Man of the Match', 'Captain']
# numerical_Data = ['Score', 'Batting Order', 'Inn.']
# st.set_page_config(layout='wide')
image = "Virat_Kohli.jpg"
st.set_page_config(page_title="Virat Kohli Century Analysis 🏏", page_icon=":bar_chart:", layout="wide")
st.title("Virat Kohli Century Analysis 🏏")
uploaded_file = st.file_uploader("Upoad the File",type=['csv','xlsx'])
if uploaded_file is not None:
if uploaded_file.name.endswith('.csv'):
data = pd.read_csv(uploaded_file)
elif uploaded_file.name.endswith(('.xls', '.xlsx')):
data = pd.read_excel(uploaded_file, engine='openpyxl')
else:
st.error("Unsupported file type. Please upload a CSV or Excel file.")
st.stop()
st.image(image,caption="Virat Kohli",use_column_width=True)
st.write("Data: ",data)
st.title('Bar Graph')
df = pd.DataFrame(data)
col_x, col_y = st.columns(2)
selected_columns_out_notout = col_x.selectbox("Out/Not Out",df.columns)
selected_columns_against = col_y.selectbox("Against",df.columns)
try:
chart_data = df.groupby([selected_columns_out_notout,selected_columns_against]).size().unstack()
st.bar_chart(chart_data)
except Exception as e:
st.error(f"Error {e}")
st.write(df)
st.text("")
st.title("Pie Chart")
default_line_columns_cat = ['Out/Not Out', 'Against']
default_line_columns_num = ['Score', 'Batting Order']
selected_columns_pie_chart = st.multiselect('select columns ',df.columns,default=default_line_columns_cat)
for col in selected_columns_pie_chart:
if col in ['Out/Not Out', 'Against', 'Venue', 'Column1', 'H/A', 'Date', 'Result','Format', 'Man of the Match', 'Captain']:
fig = px.pie(df,names=col,title=f"Pie chart for {col}")
st.plotly_chart(fig)
for col in selected_columns_pie_chart:
if col in ['Score', 'Batting Order', 'Inn.']:
fig = px.pie(df,values=col,title=f"Pie chart for {col}")
st.plotly_chart(fig)
st.title('Count Plot')
default_line_columns_0 = ['Out/Not Out', 'Against',]
selected_categorical_columns = st.multiselect("Select categorical columns for count plots", [col for col in df.columns if col not in ['Score', 'Batting Order', 'Inn.']],default=default_line_columns_0)
for col in selected_categorical_columns:
fig = px.histogram(df, x=col, title=f'Count Plot for {col}')
st.plotly_chart(fig)
st.title("Scatter Plot")
default_line_columns1 = ['Score', 'Inn.']
selected_numerical_data_scatter = st.multiselect('select numerical Data',['Score', 'Batting Order', 'Inn.'],default=default_line_columns1)
for col in selected_numerical_data_scatter:
fig = px.scatter(df,x=col,y='Score',color='Against',title=f"Scatter Plot of {col} vs Score")
st.plotly_chart(fig)
st.title('Line Chart')
default_line_columns = ['Score', 'Inn.']
selected_numerical_data_line = st.multiselect('select numerical data',['Score', 'Batting Order', 'Inn.'],default=default_line_columns)
for col in selected_numerical_data_line:
fig = px.line(df, x='Date',y=col,color='Against',title=f"Line chart of {col} over time")
st.plotly_chart(fig)
st.title('Radar Chart')
default_line_columns = ['Score', 'Inn.']
selected_numerical_data_radar = st.multiselect('select the col',['Score', 'Batting Order', 'Inn.'],default=default_line_columns)
fig = go.Figure()
for col in selected_numerical_data_radar:
fig.add_trace(go.Scatterpolar(
r = df[col],
theta = df['Against'],
fill='toself',
name=col,
))
fig.update_layout(
polar=dict(
radialaxis=dict(
visible=True,
)),
showlegend=True
)
st.plotly_chart(fig)
st.title('Heat Map')
numrical_col = df.select_dtypes(include=['int','float']).columns
fig = px.imshow(df[numrical_col].corr(),labels=dict(color='Correlation'))
fig.update_layout(height=500,width=700,title='Correaltion HeatMap')
st.plotly_chart(fig)
st.title("Violin Chart")
col_x_, col_y_ = st.columns(2)
select_categorical = col_x_.selectbox('select cat data',df.select_dtypes(include='object').columns)
select_numerical = col_y_.selectbox('select num data',df.select_dtypes(include='number').columns)
fig = px.violin(df,x=select_categorical,y=select_numerical,box=True,points='all',
title=f"Violin Plot: {select_numerical} by {select_categorical}")
st.plotly_chart(fig)
hide_st_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
header {visibility: hidden;}
</style>
"""
st.markdown(hide_st_style, unsafe_allow_html=True)