In [1]:
Copied!
from kloppy import sportscode
dataset = sportscode.load(
data="../../kloppy/tests/files/code_xml.xml"
)
dataset.to_df().head()
from kloppy import sportscode
dataset = sportscode.load(
data="../../kloppy/tests/files/code_xml.xml"
)
dataset.to_df().head()
Out[1]:
code_id | period_id | timestamp | end_timestamp | code | Team | Packing.Value | Receiver | Expected.Goal.Value | |
---|---|---|---|---|---|---|---|---|---|
0 | P1 | 1 | 3.6 | 9.7 | PASS | Henkie | 1.0 | Klaas Nøme | NaN |
1 | P2 | 1 | 68.3 | 74.5 | PASS | Henkie | 3.0 | Piet | NaN |
2 | P3 | 1 | 103.6 | 109.6 | SHOT | Henkie | NaN | NaN | 0.13 |
Save load files¶
In [2]:
Copied!
from kloppy import sportscode
sportscode.save(dataset, "/tmp/file.xml")
with open("/tmp/file.xml", "r") as fp:
data = fp.read()
print(data)
from kloppy import sportscode
sportscode.save(dataset, "/tmp/file.xml")
with open("/tmp/file.xml", "r") as fp:
data = fp.read()
print(data)
<?xml version='1.0' encoding='utf-8'?> <file> <ALL_INSTANCES> <instance> <ID>P1</ID> <start>3.6</start> <end>9.7</end> <code>PASS</code> <label> <group>Team</group> <text>Henkie</text> </label> <label> <group>Packing.Value</group> <text>1</text> </label> <label> <group>Receiver</group> <text>Klaas Nøme</text> </label> </instance> <instance> <ID>P2</ID> <start>68.3</start> <end>74.5</end> <code>PASS</code> <label> <group>Team</group> <text>Henkie</text> </label> <label> <group>Packing.Value</group> <text>3</text> </label> <label> <group>Receiver</group> <text>Piet</text> </label> </instance> <instance> <ID>P3</ID> <start>103.6</start> <end>109.6</end> <code>SHOT</code> <label> <group>Team</group> <text>Henkie</text> </label> <label> <group>Expected.Goal.Value</group> <text>0.13</text> </label> </instance> </ALL_INSTANCES> </file>