Data Description Example

Gather data:

Code
from datavolley import read_dv
import pandas as pd
import urllib.request
datavolleyfile="&stuttgart-schwerin-2018.dvw"
url_source_file = "https://raw.githubusercontent.com/openvolley/ovva/master/inst/extdata/demo/%26stuttgart-schwerin-2018.dvw"
source = urllib.request.urlopen(url_source_file).read().decode('UTF-8')
# Scrittura dei dati in un file locale
with open(datavolleyfile, 'w') as file:
    file.write(source)

Read data:

Code
# change this if you have your file
datavolleyfile="&stuttgart-schwerin-2018.dvw"
# Reading the file
dvf = read_dv.DataVolley(datavolleyfile)
# extract all the actions
plays = dvf.get_plays()

Evaluate match data:

Code
championship = dvf.match_info.championship.values[0]
print(championship)
match_day = dvf.match_info.day.values[0]
print(match_day)
match_time = dvf.match_info.time.values[0]
print(match_time)
match_season = dvf.match_info.season.values[0]
print(match_season)
1. Bundesliga Frauen - 1. Bundesliga Frauen - Playoffs
21/04/2018
19.30.00
2017/2018
Code
total_minutes = dvf.sets_info.duration.sum()
print(total_minutes)
hours = total_minutes // 60
print(hours)
minutes = total_minutes % 60
print(minutes)
137
2
17
Code
string_sets = ""
duraton_sets = ""
for idx, row in dvf.sets_info.iterrows():
   string_sets += "(" + str(row["home4"]) + "-" + str(row["visitor4"]) + ") "
   duraton_sets += str(row["duration"]) + "',"
duration_sets = duraton_sets.rstrip(",")
print(string_sets)
print(duration_sets)
(25-21) (22-25) (22-25) (25-21) (12-15) 
27',29',30',30',21'

Putting it all together:

Code
print("""
%s - %s
%s
%s - %s 
%s-%s %s
duration: %s:%sh (%s)
""" % (match_day, match_time, championship, dvf.home_team, 
       dvf.visiting_team, dvf.home_setswon, dvf.visiting_setswon,
       string_sets,str(hours).zfill(2), str(minutes).zfill(2), duration_sets))

21/04/2018 - 19.30.00
1. Bundesliga Frauen - 1. Bundesliga Frauen - Playoffs
Allianz MTV Stuttgart - SSC Palmberg Schwerin 
2-3 (25-21) (22-25) (22-25) (25-21) (12-15) 
duration: 02:17h (27',29',30',30',21')
Code
print(dvf.home_team)
print("name\tname")
players = dvf.players_home
players['player_number'] = pd.to_numeric(players['player_number'], errors='coerce')
players = players.sort_values("player_number")
plays = dvf.get_plays()
for idx, row in players.iterrows():
    player_number = row["player_number"]
    player_name = row['player_name'].rstrip()
    player_id = row['player_id']
    points = plays[(plays.player_id == player_id) & plays.skill.isin(['Attack', 'Serve','Block']) & (plays.evaluation_code == "#")].shape[0]
    errors = plays[(plays.player_id == player_id) & plays.skill.isin(['Attack', 'Reception','Dig','Set','Block']) & (plays.evaluation_code == "=")].shape[0]
    print("""%s\t%s (%i,%i)""" % (player_number,player_name, points, errors))
print("coaches")
print(" " + dvf.home_coaches[0])
print(" " + dvf.home_coaches[1])
print("\nin parentheses: number of points, number of errors")
Allianz MTV Stuttgart
name    name
1   Nikoleta Perovic (21,3)
2   Femke Stoltenborg (2,1)
3   Micheli Tomazela Pissinato (0,0)
5   Mallory Grace McCage (16,4)
6   Annie Cesar (0,2)
7   Renata Sandor (12,10)
8   Julia Schaefer (1,1)
10  Pia Kästner (1,0)
11  Teodora Pusic (0,0)
12  Deborah van Daelen (5,3)
14  Jenna Potts (0,0)
16  Michaela Mlejnkova (18,5)
17  Paige Tapp (7,2)
coaches
 Athanasopoulos Giannis
 Paraschidis I, Miyashiro T

in parentheses: number of points, number of errors

Print home coaches:

Code
print(dvf.home_coaches[0])
Athanasopoulos Giannis
Code
print(dvf.visiting_team)
print("name\tname")
players = dvf.players_visiting
players['player_number'] = pd.to_numeric(players['player_number'], errors='coerce')
players = players.sort_values("player_number")
plays = dvf.get_plays()
for idx, row in players.iterrows():
    player_number = row["player_number"]
    player_name = row['player_name'].rstrip()
    player_id = row['player_id']
    points = plays[(plays.player_id == player_id) & plays.skill.isin(['Attack', 'Serve','Block']) & (plays.evaluation_code == "#")].shape[0]
    errors = plays[(plays.player_id == player_id) & plays.skill.isin(['Attack', 'Reception','Dig','Set','Block']) & (plays.evaluation_code == "=")].shape[0]
    print("""%s\t%s (%i,%i)""" % (player_number,player_name, points, errors))
print("coaches")
print(" " + dvf.visiting_coaches[0])
print(" " + dvf.visiting_coaches[1])
print("\nin parentheses: number of points, number of errors")
SSC Palmberg Schwerin
name    name
1   Greta Szakmáry (25,8)
2   Martenne Julia Bettendorf (0,0)
3   Louisa Lippmann (20,9)
5   Sabrina Krause (0,0)
6   Jennifer Geerties (11,5)
7   Luna Veronica Carocci (0,3)
8   Kaisa Alanko (1,1)
10  Denise Hanke (6,4)
11  Beta Dumancic (12,0)
12  Lauren Barfield (9,0)
14  Elisa Lohmann (0,0)
15  Jelena Oluic (2,0)
16  Marie Schölzel (0,0)
coaches
 Koslowski Felix
 Hartmann M, Sens P

in parentheses: number of points, number of errors