---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[6], line 1
----> 1 api.getEvents([232434], include_kpis=True, include_set_pieces=True)
File c:\Users\tiago\AppData\Local\Programs\Python\Python312\Lib\site-packages\impectPy\impect.py:48, in Impect.getEvents(self, matches, include_kpis, include_set_pieces)
47 def getEvents(self, matches: list, include_kpis: bool = True, include_set_pieces: bool = True) -> pd.DataFrame:
---> 48 return getEventsFromHost(
49 matches, include_kpis, include_set_pieces, self.connection, self.__config.HOST
50 )
File c:\Users\tiago\AppData\Local\Programs\Python\Python312\Lib\site-packages\impectPy\events.py:284, in getEventsFromHost(matches, include_kpis, include_set_pieces, connection, host)
211 events = events.merge(
212 squads[["id", "name"]].rename(columns={"id": "squadId", "name": "squadName"}),
213 left_on="squadId",
(...) 280 suffixes=("", "_right")
281 )
283 if not coaches_blacklisted:
--> 284 events = events.merge(
285 coaches[["id", "name"]].rename(columns={"id": "homeCoachId", "name": "homeCoachName"}),
286 left_on="homeSquadCoachId",
287 right_on="homeCoachId",
288 how="left",
289 suffixes=("", "_right")
290 ).merge(
291 coaches[["id", "name"]].rename(columns={"id": "awayCoachId", "name": "awayCoachName"}),
292 left_on="awaySquadCoachId",
293 right_on="awayCoachId",
294 how="left",
295 suffixes=("", "_right")
296 )
298 if include_kpis:
299 # unnest scorings and full join with kpi list to ensure all kpis are present
300 scorings = scorings.merge(kpis, left_on="kpiId", right_on="id", how="outer") \
301 .sort_values("kpiId") \
302 .drop("kpiId", axis=1) \
(...) 306 .reset_index() \
307 .loc[lambda df: df["eventId"].notna()]
File c:\Users\tiago\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\frame.py:10859, in DataFrame.merge(self, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
10840 @Substitution("")
10841 @Appender(_merge_doc, indents=2)
10842 def merge(
(...) 10855 validate: MergeValidate | None = None,
10856 ) -> DataFrame:
10857 from pandas.core.reshape.merge import merge
> 10859 return merge(
10860 self,
10861 right,
10862 how=how,
10863 on=on,
10864 left_on=left_on,
10865 right_on=right_on,
10866 left_index=left_index,
10867 right_index=right_index,
10868 sort=sort,
10869 suffixes=suffixes,
10870 copy=copy,
10871 indicator=indicator,
10872 validate=validate,
10873 )
File c:\Users\tiago\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\reshape\merge.py:170, in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
155 return _cross_merge(
156 left_df,
157 right_df,
(...) 167 copy=copy,
168 )
169 else:
--> 170 op = _MergeOperation(
171 left_df,
172 right_df,
173 how=how,
174 on=on,
175 left_on=left_on,
176 right_on=right_on,
177 left_index=left_index,
178 right_index=right_index,
179 sort=sort,
180 suffixes=suffixes,
181 indicator=indicator,
182 validate=validate,
183 )
184 return op.get_result(copy=copy)
File c:\Users\tiago\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\reshape\merge.py:807, in _MergeOperation.__init__(self, left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, indicator, validate)
803 self._validate_tolerance(self.left_join_keys)
805 # validate the merge keys dtypes. We may need to coerce
806 # to avoid incompatible dtypes
--> 807 self._maybe_coerce_merge_keys()
809 # If argument passed to validate,
810 # check if columns specified as unique
811 # are in fact unique.
812 if validate is not None:
File c:\Users\tiago\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\reshape\merge.py:1509, in _MergeOperation._maybe_coerce_merge_keys(self)
1503 # unless we are merging non-string-like with string-like
1504 elif (
1505 inferred_left in string_types and inferred_right not in string_types
1506 ) or (
1507 inferred_right in string_types and inferred_left not in string_types
1508 ):
-> 1509 raise ValueError(msg)
1511 # datetimelikes must match exactly
1512 elif needs_i8_conversion(lk.dtype) and not needs_i8_conversion(rk.dtype):
ValueError: You are trying to merge on object and int64 columns for key 'homeSquadCoachId'. If you wish to proceed you should use pd.concat