Skip to content

Commit 637ff86

Browse files
committed
initialize repository
0 parents  commit 637ff86

File tree

8 files changed

+24069
-0
lines changed

8 files changed

+24069
-0
lines changed

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dash_lib.iml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_2.py

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from dash import Dash, dcc, Output, Input
2+
import dash_bootstrap_components as dbc
3+
import plotly.express as px
4+
import numpy as np
5+
import pandas as pd
6+
7+
8+
def main():
9+
print("bonjounrno")
10+
11+
# "Wykres 1: Wybierasz dana druzyne a nastepnie"
12+
# Masz o tej druzynie tworzony dashboard
13+
# Liczba goli strzelonych w sumie, liczba straconych, bilans goli (strzelone - stracone)
14+
# Przeciwnik najtrudniejszy, przeciwnik najlatwiejszy
15+
# Najlepszy mecz, najgorszy mecz
16+
17+
# Wykres 2: Wybierasz 2 druzyny i masz rozne dane
18+
# Kiedy jakie mecze byly i jakie byly wyniki
19+
20+
# maybe take the data from world championship soccer 2022 !!! ->
21+
22+
23+
def generate_graph_1():
24+
df = pd.read_csv("C:/Users/Uzytkownik/PycharmProjects/dash_lib/international_matches.csv")
25+
26+
df_brazil = df[(df["home_team"] == "Brazil") | (df["away_team"] == "Brazil")]
27+
print(df_brazil)
28+
29+
#ad.1 liczba strzelonych goli w sumie
30+
31+
#gdy byli gospodarzami
32+
liczba_meczy_jako_gospodarz = len(df_brazil.loc[df["home_team"] == "Brazil"])
33+
liczba_goli_g = df_brazil.loc[df["home_team"] == "Brazil"]['home_team_score'].sum()
34+
print(f"Liczba goli jako gospodarze: {liczba_goli_g}")
35+
print(f"liczba meczy jako gospodarze: {liczba_meczy_jako_gospodarz}")
36+
37+
#gdy nie byli gospodarzemi
38+
liczba_meczy_jako_nie_gospodarze = len(df_brazil.loc[df["away_team"] == "Brazil"])
39+
liczba_goli_ng = df_brazil.loc[df["away_team"] == "Brazil"]['away_team_score'].sum()
40+
print(f"Liczba goli jako NIE gospodarze: {liczba_goli_ng}")
41+
print(f"liczba meczy jako NIE gospodarze: {liczba_meczy_jako_nie_gospodarze}")
42+
43+
liczba_meczy_suma = liczba_meczy_jako_nie_gospodarze + liczba_meczy_jako_gospodarz
44+
liczba_goli_suma = liczba_goli_g + liczba_goli_ng
45+
print(f"Liczba meczow w sumie: {liczba_meczy_suma} \n"
46+
f"liczba golow w sumie: {liczba_goli_suma}")
47+
48+
49+
#ad.2 liczba straconych goli
50+
51+
52+
def analyze_data():
53+
df = pd.read_csv("C:/Users/Uzytkownik/PycharmProjects/dash_lib/international_matches.csv")
54+
print(df.head(5))
55+
print(df.columns)
56+
print(df.info)
57+
print(df.describe())
58+
print(df.date)
59+
60+
61+
if __name__ == '__main__':
62+
generate_graph_1()

international_matches.csv

+23,922
Large diffs are not rendered by default.

main.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from dash import Dash, dcc, Output, Input
2+
import dash_bootstrap_components as dbc
3+
import plotly.express as px
4+
import numpy as np
5+
import pandas as pd
6+
7+
8+
def main():
9+
10+
#initialize the app with theme
11+
app = Dash(__name__, external_stylesheets=[dbc.themes.FLATLY])
12+
13+
#get data frame
14+
df = px.data.medals_long()
15+
16+
#building components
17+
my_title = dcc.Markdown(children='My first graph in DASH')
18+
my_graph = dcc.Graph(figure={})
19+
dropdown = dcc.Dropdown(options=['Bar Plot', 'Scatter Plot'],
20+
value='Bar Plot',
21+
clearable=False)
22+
23+
24+
#customize layout
25+
app.layout = dbc.Container([my_title, my_graph,dropdown])
26+
27+
#allowing components to interact with each other
28+
@app.callback(
29+
Output(my_graph, component_property='figure'),
30+
Input(dropdown, component_property='value')
31+
)
32+
def update_graph(user_input):
33+
if (user_input=='Bar Plot'):
34+
fig = px.bar(data_frame=df, x="nation", y="count", color="medal",
35+
title="Elegancki bar plot")
36+
elif (user_input=="Scatter Plot"):
37+
fig = px.scatter(data_frame=df, x = "count", y="nation", color="medal",
38+
title="Elegancki Scatter Plot",
39+
labels={
40+
"count": "licznosc",
41+
"nation": "Panstwo, nacja",
42+
"medal":"jaki medal"
43+
})
44+
return fig
45+
46+
# run the app
47+
app.run_server(port=8052)
48+
49+
50+
#maybe take the data from world championship soccer 2022 !!! ->
51+
52+
53+
if __name__ == '__main__':
54+
main()

0 commit comments

Comments
 (0)