ForzaJuve1
commited on
Commit
•
6259d93
1
Parent(s):
491eca5
Update Integration.py
Browse files- Integration.py +39 -21
Integration.py
CHANGED
@@ -551,39 +551,57 @@ class Euro2020Dataset(GeneratorBasedBuilder):
|
|
551 |
|
552 |
# Increase the maximum field size limit
|
553 |
#csv.field_size_limit(sys.maxsize)
|
|
|
|
|
|
|
|
|
|
|
554 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
def _generate_examples(self, filepath):
|
556 |
|
557 |
table = pq.read_table(filepath)
|
558 |
df = table.to_pandas()
|
559 |
#df = pd.read_parquet(filepath)
|
560 |
for id, row in df.iterrows():
|
561 |
-
MatchEvent_dict
|
|
|
|
|
|
|
|
|
|
|
562 |
|
563 |
-
if row.get("MatchEvent",{}) is not None:
|
564 |
-
MatchEvent = row.get("MatchEvent",{})
|
565 |
-
for key in MatchEvent.keys():
|
566 |
-
MatchEvent_dict[key] = MatchEvent[key]
|
567 |
|
568 |
-
if row.get("TeamLineUps",{}) is not None:
|
569 |
-
TeamLineUps = row.get("TeamLineUps",{})
|
570 |
-
for key in TeamLineUps.keys():
|
571 |
-
TeamLineUps_dict[key] = TeamLineUps[key]
|
572 |
|
573 |
-
if row.get("TeamStats",{}) is not None:
|
574 |
-
TeamStats = row.get("TeamStats",{})
|
575 |
-
for key in TeamStats.keys():
|
576 |
-
TeamStats_dict[key] = TeamStats[key]
|
577 |
|
578 |
-
if row.get("PlayerStats",{}) is not None:
|
579 |
-
PlayerStats = row.get("PlayerStats",{})
|
580 |
-
for key in PlayerStats.keys():
|
581 |
-
PlayerStats_dict[key] = PlayerStats[key]
|
582 |
|
583 |
-
if row.get("PlayerPreMatchInfo",{}) is not None:
|
584 |
-
PlayerPreMatchInfo = row.get("PlayerPreMatchInfo",{})
|
585 |
-
for key in PlayerPreMatchInfo.keys():
|
586 |
-
PlayerPreMatchInfo_dict[key] = PlayerPreMatchInfo[key]
|
587 |
|
588 |
#'id' here is the index of the row in the DataFrame
|
589 |
#'row' is a Pandas Series object representing the row data
|
|
|
551 |
|
552 |
# Increase the maximum field size limit
|
553 |
#csv.field_size_limit(sys.maxsize)
|
554 |
+
|
555 |
+
def process_nested_dict(d):
|
556 |
+
# Recursively process a nested dictionary
|
557 |
+
if not isinstance(d, dict):
|
558 |
+
return d
|
559 |
|
560 |
+
processed_dict = {}
|
561 |
+
for key, value in d.items():
|
562 |
+
if isinstance(value, dict):
|
563 |
+
processed_dict[key] = process_nested_dict(value)
|
564 |
+
else:
|
565 |
+
processed_dict[key] = value
|
566 |
+
return processed_dict
|
567 |
+
|
568 |
def _generate_examples(self, filepath):
|
569 |
|
570 |
table = pq.read_table(filepath)
|
571 |
df = table.to_pandas()
|
572 |
#df = pd.read_parquet(filepath)
|
573 |
for id, row in df.iterrows():
|
574 |
+
MatchEvent_dict = process_nested_dict(row.get("MatchEvent", {}))
|
575 |
+
TeamLineUps_dict = process_nested_dict(row.get("TeamLineUps", {}))
|
576 |
+
TeamStats_dict = process_nested_dict(row.get("TeamStats", {}))
|
577 |
+
PlayerStats_dict = process_nested_dict(row.get("PlayerStats", {}))
|
578 |
+
PlayerPreMatchInfo_dict = process_nested_dict(row.get("PlayerPreMatchInfo", {}))
|
579 |
+
#MatchEvent_dict, TeamLineUps_dict, TeamStats_dict, PlayerStats_dict, PlayerPreMatchInfo_dict = {}, {}, {}, {}, {}
|
580 |
|
581 |
+
#if row.get("MatchEvent",{}) is not None:
|
582 |
+
#MatchEvent = row.get("MatchEvent",{})
|
583 |
+
#for key in MatchEvent.keys():
|
584 |
+
#MatchEvent_dict[key] = MatchEvent[key]
|
585 |
|
586 |
+
#if row.get("TeamLineUps",{}) is not None:
|
587 |
+
#TeamLineUps = row.get("TeamLineUps",{})
|
588 |
+
#for key in TeamLineUps.keys():
|
589 |
+
#TeamLineUps_dict[key] = TeamLineUps[key]
|
590 |
|
591 |
+
#if row.get("TeamStats",{}) is not None:
|
592 |
+
#TeamStats = row.get("TeamStats",{})
|
593 |
+
#for key in TeamStats.keys():
|
594 |
+
#TeamStats_dict[key] = TeamStats[key]
|
595 |
|
596 |
+
#if row.get("PlayerStats",{}) is not None:
|
597 |
+
#PlayerStats = row.get("PlayerStats",{})
|
598 |
+
#for key in PlayerStats.keys():
|
599 |
+
#PlayerStats_dict[key] = PlayerStats[key]
|
600 |
|
601 |
+
#if row.get("PlayerPreMatchInfo",{}) is not None:
|
602 |
+
#PlayerPreMatchInfo = row.get("PlayerPreMatchInfo",{})
|
603 |
+
#for key in PlayerPreMatchInfo.keys():
|
604 |
+
#PlayerPreMatchInfo_dict[key] = PlayerPreMatchInfo[key]
|
605 |
|
606 |
#'id' here is the index of the row in the DataFrame
|
607 |
#'row' is a Pandas Series object representing the row data
|