Match
MatchDataSchema
Bases: DataFrameModel
A panderas.DataFrameModel for team information.
Provider-specific match identifier fields are added before validation during MatchSyncableContent.validate_data_schema().
competition_id and season_id must be provided when using MatchSyncEngine.use_competition_context.
Source code in src/glass_onion/match.py
away_team_id = Field(nullable=False, coerce=True)
class-attribute
instance-attribute
The team identifier of the away team. This is assumed to be universally unique across the MatchSyncableContent objects provided to MatchSyncEngine.
competition_id = Field(nullable=False, coerce=True)
class-attribute
instance-attribute
The competition of the match. This is assumed to be universally unique across the MatchSyncableContent objects provided to TeamSyncEngine.
home_team_id = Field(nullable=False, coerce=True)
class-attribute
instance-attribute
The team identifier of the home team. This is assumed to be universally unique across the MatchSyncableContent objects provided to MatchSyncEngine.
match_date = Field(nullable=False)
class-attribute
instance-attribute
The date of the match. Preferably in YYYY-MM-DD format, but required to be in a date format that can be parsed by pandas.Timestamp.
matchday = Field(nullable=True, coerce=True)
class-attribute
instance-attribute
The matchday (AKA: match-week or match round) of the match in its given competition and season.
season_id = Field(nullable=False, coerce=True)
class-attribute
instance-attribute
The season of the match. This is assumed to be universally unique across the MatchSyncableContent objects provided to TeamSyncEngine.
MatchSyncEngine
Bases: SyncEngine
A subclass of SyncEngine to use for match objects.
See synchronize_pair()[glass_onion.player.MatchSyncEngine.synchronize_pair] for methodology details.
Source code in src/glass_onion/match.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
__init__(content, use_competition_context=False, verbose=False)
Creates a new MatchSyncEngine object. Setting use_competition_context adds competition_id and season_id (assumed to be universal across all data providers) to join_columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
list[str]
|
a list of SyncableContent objects. |
required |
use_competition_context
|
bool
|
should the competition context (IE: columns |
False
|
verbose
|
bool
|
a flag to verbose logging. This will be |
False
|
Source code in src/glass_onion/match.py
synchronize_on_adjusted_dates(input1, input2, date_adjustment)
Synchronizes two MatchSyncableContent objects after adjusting the match_date field of input1 by date_adjustment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input1
|
SyncableContent
|
a SyncableContent object. |
required |
input2
|
SyncableContent
|
a SyncableContent object. |
required |
date_adjustment
|
`pandas.Timedelta`
|
a time period to adjust |
required |
Returns:
a pandas.DataFrame object that contains synchronized identifier pairs from input1 and input2. The available columns are the id_field values of input1 and input2.
Source code in src/glass_onion/match.py
synchronize_on_matchday(input1, input2)
Synchronizes two MatchSyncableContent objects using matchday instead of match_date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input1
|
SyncableContent
|
a SyncableContent object. |
required |
input2
|
SyncableContent
|
a SyncableContent object. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
a |
Source code in src/glass_onion/match.py
synchronize_pair(input1, input2)
Synchronizes two MatchSyncableContent objects.
Methodology
- Attempt to join pair using
match_date,home_team_id, andaway_team_id. - Account for matches with different dates across data providers (timezones, TV scheduling, etc) by adjusting
match_datein one dataset in the pair by -3 to 3 days, then attempting synchronization usingmatch_date,home_team_id, andaway_team_idagain. This process is then repeated for the other dataset in the pair. - Account for matches postponed to a different date outside the [-3, 3] day range by attempting synchronization using
matchday,home_team_id, andaway_team_id(ifmatchdayis available).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input1
|
SyncableContent
|
a MatchSyncableContent object from |
required |
input2
|
SyncableContent
|
a MatchSyncableContent object from |
required |
Returns:
| Type | Description |
|---|---|
SyncableContent
|
If |
SyncableContent
|
If |
SyncableContent
|
If both dataframes are non-empty, returns a new MatchSyncableContent object with synchronized identifiers from |
Source code in src/glass_onion/match.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
MatchSyncableContent
Bases: SyncableContent
A subclass of SyncableContent to use for match objects.
Source code in src/glass_onion/match.py
validate_data_schema()
Checks if this object's data meets the schema requirements for this object type. See MatchDataSchema for more details.
Raises:
| Type | Description |
|---|---|
SchemaError
|
if |
Returns:
| Type | Description |
|---|---|
bool
|
True, if |