In [105]:
import pandas as pd
from pandas import DataFrame
import matplotlib.pyplot as plt
# get weekly score
week_df = pd.read_csv("../data/Never Ending_week1_score.csv", encoding = "ISO-8859-1")
week_df
Out[105]:
Team Name
FG%
FT%
3PTM
PTS
OREB
REB
AST
ST
BLK
TO
A/T
Total
0
xiuxian
20.0
13.0
5.0
6.0
14.5
15.0
4.0
10.0
11.0
4.0
2.0
104.5
1
C3-??????
19.0
6.0
18.0
15.0
19.0
12.0
10.5
13.5
13.0
16.0
16.0
158.0
2
D5 - ????
18.0
1.0
1.0
1.0
2.0
4.0
2.0
1.0
18.0
18.0
4.0
70.0
3
C4-lebronjames
17.0
7.0
9.0
13.0
6.0
5.0
19.0
17.5
17.0
10.0
18.5
139.0
4
C1-Lydia
16.0
5.0
11.5
5.0
17.0
9.0
12.0
15.0
12.0
12.0
12.0
126.5
5
D4-????
15.0
16.0
6.0
18.0
14.5
10.0
17.0
16.0
19.0
3.0
11.0
145.5
6
A1
14.0
10.5
7.0
4.0
4.5
2.0
3.0
6.0
5.0
17.0
7.0
80.0
7
A2-??????????
12.5
4.0
17.0
19.0
18.0
20.0
9.0
11.5
2.0
1.0
3.0
117.0
8
A4-??????
12.5
18.0
11.5
8.0
3.0
7.0
5.0
17.5
7.5
14.0
9.0
113.0
9
C2-Stephen
11.0
19.0
13.0
12.0
8.0
11.0
20.0
7.0
7.5
2.0
17.0
127.5
10
D3 - ?U?U
10.0
2.0
2.0
2.0
4.5
3.0
1.0
2.0
5.0
20.0
1.0
52.5
11
D1-????
9.0
20.0
15.0
11.0
13.0
6.0
7.0
4.5
14.0
8.0
6.0
113.5
12
B2-Sin
7.5
9.0
14.0
9.0
20.0
18.0
16.0
20.0
16.0
13.0
18.5
161.0
13
B5-dragonball
7.5
17.0
16.0
20.0
7.0
13.5
13.0
9.0
10.0
7.0
8.0
128.0
14
B3-Jordan
6.0
3.0
8.0
10.0
16.0
19.0
6.0
4.5
20.0
5.5
5.0
103.0
15
B1-pippo
5.0
14.5
4.0
7.0
10.0
17.0
8.0
3.0
1.0
11.0
10.0
90.5
16
A5-Gray Potato
4.0
8.0
19.0
14.0
9.0
8.0
15.0
11.5
15.0
9.0
13.5
126.0
17
A3-Marsmnky
3.0
10.5
20.0
17.0
11.0
16.0
10.5
19.0
3.0
15.0
13.5
138.5
18
C5-unbe
2.0
12.0
10.0
16.0
12.0
13.5
18.0
13.5
9.0
5.5
15.0
126.5
19
B4-????????
1.0
14.5
3.0
3.0
1.0
1.0
14.0
8.0
5.0
19.0
20.0
89.5
In [106]:
# sort weekly score by name
week_df.sort_values(['Team Name'], ascending=[True], inplace=True)
week_df
Out[106]:
Team Name
FG%
FT%
3PTM
PTS
OREB
REB
AST
ST
BLK
TO
A/T
Total
6
A1
14.0
10.5
7.0
4.0
4.5
2.0
3.0
6.0
5.0
17.0
7.0
80.0
7
A2-??????????
12.5
4.0
17.0
19.0
18.0
20.0
9.0
11.5
2.0
1.0
3.0
117.0
17
A3-Marsmnky
3.0
10.5
20.0
17.0
11.0
16.0
10.5
19.0
3.0
15.0
13.5
138.5
8
A4-??????
12.5
18.0
11.5
8.0
3.0
7.0
5.0
17.5
7.5
14.0
9.0
113.0
16
A5-Gray Potato
4.0
8.0
19.0
14.0
9.0
8.0
15.0
11.5
15.0
9.0
13.5
126.0
15
B1-pippo
5.0
14.5
4.0
7.0
10.0
17.0
8.0
3.0
1.0
11.0
10.0
90.5
12
B2-Sin
7.5
9.0
14.0
9.0
20.0
18.0
16.0
20.0
16.0
13.0
18.5
161.0
14
B3-Jordan
6.0
3.0
8.0
10.0
16.0
19.0
6.0
4.5
20.0
5.5
5.0
103.0
19
B4-????????
1.0
14.5
3.0
3.0
1.0
1.0
14.0
8.0
5.0
19.0
20.0
89.5
13
B5-dragonball
7.5
17.0
16.0
20.0
7.0
13.5
13.0
9.0
10.0
7.0
8.0
128.0
4
C1-Lydia
16.0
5.0
11.5
5.0
17.0
9.0
12.0
15.0
12.0
12.0
12.0
126.5
9
C2-Stephen
11.0
19.0
13.0
12.0
8.0
11.0
20.0
7.0
7.5
2.0
17.0
127.5
1
C3-??????
19.0
6.0
18.0
15.0
19.0
12.0
10.5
13.5
13.0
16.0
16.0
158.0
3
C4-lebronjames
17.0
7.0
9.0
13.0
6.0
5.0
19.0
17.5
17.0
10.0
18.5
139.0
18
C5-unbe
2.0
12.0
10.0
16.0
12.0
13.5
18.0
13.5
9.0
5.5
15.0
126.5
11
D1-????
9.0
20.0
15.0
11.0
13.0
6.0
7.0
4.5
14.0
8.0
6.0
113.5
10
D3 - ?U?U
10.0
2.0
2.0
2.0
4.5
3.0
1.0
2.0
5.0
20.0
1.0
52.5
5
D4-????
15.0
16.0
6.0
18.0
14.5
10.0
17.0
16.0
19.0
3.0
11.0
145.5
2
D5 - ????
18.0
1.0
1.0
1.0
2.0
4.0
2.0
1.0
18.0
18.0
4.0
70.0
0
xiuxian
20.0
13.0
5.0
6.0
14.5
15.0
4.0
10.0
11.0
4.0
2.0
104.5
In [107]:
total_df = pd.read_csv("../data/Never Ending_week0_score.csv", encoding = "ISO-8859-1")
total_df
Out[107]:
Team Name
FG%
FT%
3PTM
PTS
OREB
REB
AST
ST
BLK
TO
A/T
Total
0
D4-????
6.0
3.0
8.0
10.0
16.0
19.0
6.0
4.5
20.0
5.5
5.0
103.0
1
A1
5.0
14.5
4.0
7.0
10.0
17.0
8.0
3.0
1.0
11.0
10.0
90.5
2
A2-??????????
16.0
5.0
11.5
5.0
17.0
9.0
12.0
15.0
12.0
12.0
12.0
126.5
3
A4-??????
15.0
16.0
6.0
18.0
14.5
10.0
17.0
16.0
19.0
3.0
11.0
145.5
4
C2-Stephen
14.0
10.5
7.0
4.0
4.5
2.0
3.0
6.0
5.0
17.0
7.0
80.0
5
D3 - ?U?U
12.5
4.0
17.0
19.0
18.0
20.0
9.0
11.5
2.0
1.0
3.0
117.0
6
D1-????
12.5
18.0
11.5
8.0
3.0
7.0
5.0
17.5
7.5
14.0
9.0
113.0
7
B2-Sin
11.0
19.0
13.0
12.0
8.0
11.0
20.0
7.0
7.5
2.0
17.0
127.5
8
B5-dragonball
10.0
2.0
2.0
2.0
4.5
3.0
1.0
2.0
5.0
20.0
1.0
52.5
9
B3-Jordan
9.0
20.0
15.0
11.0
13.0
6.0
7.0
4.5
14.0
8.0
6.0
113.5
10
B1-pippo
7.5
9.0
14.0
9.0
20.0
18.0
16.0
20.0
16.0
13.0
18.5
161.0
11
A5-Gray Potato
7.5
17.0
16.0
20.0
7.0
13.5
13.0
9.0
10.0
7.0
8.0
128.0
12
A3-Marsmnky
4.0
8.0
19.0
14.0
9.0
8.0
15.0
11.5
15.0
9.0
13.5
126.0
13
C5-unbe
3.0
10.5
20.0
17.0
11.0
16.0
10.5
19.0
3.0
15.0
13.5
138.5
14
B4-????????
2.0
12.0
10.0
16.0
12.0
13.5
18.0
13.5
9.0
5.5
15.0
126.5
15
xiuxian
1.0
14.5
3.0
3.0
1.0
1.0
14.0
8.0
5.0
19.0
20.0
89.5
16
C3-??????
20.0
13.0
5.0
6.0
14.5
15.0
4.0
10.0
11.0
4.0
2.0
104.5
17
D5 - ????
19.0
6.0
18.0
15.0
19.0
12.0
10.5
13.5
13.0
16.0
16.0
158.0
18
C4-lebronjames
18.0
1.0
1.0
1.0
2.0
4.0
2.0
1.0
18.0
18.0
4.0
70.0
19
C1-Lydia
17.0
7.0
9.0
13.0
6.0
5.0
19.0
17.5
17.0
10.0
18.5
139.0
In [108]:
# sort score score by name
total_df.sort_values(['Team Name'], ascending=[True], inplace=True)
total_df
Out[108]:
Team Name
FG%
FT%
3PTM
PTS
OREB
REB
AST
ST
BLK
TO
A/T
Total
1
A1
5.0
14.5
4.0
7.0
10.0
17.0
8.0
3.0
1.0
11.0
10.0
90.5
2
A2-??????????
16.0
5.0
11.5
5.0
17.0
9.0
12.0
15.0
12.0
12.0
12.0
126.5
12
A3-Marsmnky
4.0
8.0
19.0
14.0
9.0
8.0
15.0
11.5
15.0
9.0
13.5
126.0
3
A4-??????
15.0
16.0
6.0
18.0
14.5
10.0
17.0
16.0
19.0
3.0
11.0
145.5
11
A5-Gray Potato
7.5
17.0
16.0
20.0
7.0
13.5
13.0
9.0
10.0
7.0
8.0
128.0
10
B1-pippo
7.5
9.0
14.0
9.0
20.0
18.0
16.0
20.0
16.0
13.0
18.5
161.0
7
B2-Sin
11.0
19.0
13.0
12.0
8.0
11.0
20.0
7.0
7.5
2.0
17.0
127.5
9
B3-Jordan
9.0
20.0
15.0
11.0
13.0
6.0
7.0
4.5
14.0
8.0
6.0
113.5
14
B4-????????
2.0
12.0
10.0
16.0
12.0
13.5
18.0
13.5
9.0
5.5
15.0
126.5
8
B5-dragonball
10.0
2.0
2.0
2.0
4.5
3.0
1.0
2.0
5.0
20.0
1.0
52.5
19
C1-Lydia
17.0
7.0
9.0
13.0
6.0
5.0
19.0
17.5
17.0
10.0
18.5
139.0
4
C2-Stephen
14.0
10.5
7.0
4.0
4.5
2.0
3.0
6.0
5.0
17.0
7.0
80.0
16
C3-??????
20.0
13.0
5.0
6.0
14.5
15.0
4.0
10.0
11.0
4.0
2.0
104.5
18
C4-lebronjames
18.0
1.0
1.0
1.0
2.0
4.0
2.0
1.0
18.0
18.0
4.0
70.0
13
C5-unbe
3.0
10.5
20.0
17.0
11.0
16.0
10.5
19.0
3.0
15.0
13.5
138.5
6
D1-????
12.5
18.0
11.5
8.0
3.0
7.0
5.0
17.5
7.5
14.0
9.0
113.0
5
D3 - ?U?U
12.5
4.0
17.0
19.0
18.0
20.0
9.0
11.5
2.0
1.0
3.0
117.0
0
D4-????
6.0
3.0
8.0
10.0
16.0
19.0
6.0
4.5
20.0
5.5
5.0
103.0
17
D5 - ????
19.0
6.0
18.0
15.0
19.0
12.0
10.5
13.5
13.0
16.0
16.0
158.0
15
xiuxian
1.0
14.5
3.0
3.0
1.0
1.0
14.0
8.0
5.0
19.0
20.0
89.5
In [109]:
names = week_df['Team Name'].tolist()
week_scores = week_df['Total'].tolist()
total_scores = total_df['Total'].tolist()
print(names, week_scores, total_scores)
['A1', 'A2-??????????', 'A3-Marsmnky', 'A4-??????', 'A5-Gray Potato', 'B1-pippo', 'B2-Sin', 'B3-Jordan', 'B4-????????', 'B5-dragonball', 'C1-Lydia', 'C2-Stephen', 'C3-??????', 'C4-lebronjames', 'C5-unbe', 'D1-????', 'D3 - ?U?U', 'D4-????', 'D5 - ????', 'xiuxian'] [80.0, 117.0, 138.5, 113.0, 126.0, 90.5, 161.0, 103.0, 89.5, 128.0, 126.5, 127.5, 158.0, 139.0, 126.5, 113.5, 52.5, 145.5, 70.0, 104.5] [90.5, 126.5, 126.0, 145.5, 128.0, 161.0, 127.5, 113.5, 126.5, 52.5, 139.0, 80.0, 104.5, 70.0, 138.5, 113.0, 117.0, 103.0, 158.0, 89.5]
In [111]:
pos = list(range(1, len(df['Team Name'])+1))
print(pos)
width = 0.3
# Plotting the bars
fig, ax = plt.subplots(figsize=(20,12))
# Create a bar with week score,
# in position pos,
plt.bar([p + width for p in pos],
week_scores,
# of width
width,
# with alpha 0.5
alpha=0.5,
# with color
color='#EE3224',
edgecolor='red',
# with label the first value in first_name
label='Week')
# Create a bar with mid_score data,
# in position pos + some width buffer,
plt.bar([p + 2*width for p in pos],
#using df['mid_score'] data,
total_scores,
# of width
width,
# with alpha 0.5
alpha=0.2,
# with color
color='#F78F1E',
edgecolor='#000000',
# with label the second value in first_name
label='Season')
# Set the y axis label
ax.set_ylabel('Score')
# Set the chart's title
ax.set_title('Week 1')
# Set the position of the x ticks
ax.set_xticks([p + 1.5 * width for p in pos])
# Set the labels for the x ticks
ax.set_xticklabels(names, rotation=60)
# Setting the x-axis and y-axis limits
plt.xlim(min(pos)-width, max(pos)+width*4)
plt.ylim(0, 180 )
# Adding the legend and showing the plot
plt.legend(['Week', 'Season'], loc='upper right')
plt.grid()
plt.show()
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
In [ ]:
Content source: namiszh/fba
Similar notebooks: