table_names
['tournament',
'match',
'game',
'rally',
'shot_type_ref',
'shot',
'player',
'team']
In practice, you probably just need to use:
which will load all the tables in table_names into pandas dataframes which are then usable as variables. You can probably ignore the rest of the functions here unless you want to directly access the pklmart SQL database.
These are the names of the tables that exist in the pklmart database.
load_dfs_from_csv ()
Returns a dictionary of dataframes from the table csv files
We can load these tables into a data frame using get_tab_as_df
. Note that pklshop comes with the data convienently loaded into pandas dataframes so you don’t need to use this function unless you want to connect directly to the database.
get_tab_as_df (table_name:str)
Returns a pandas dataframe for a given table
Importing pklshop.data automatically calls load_dfs_from_csv
for each table so the dataframes are already loaded from import. Here’s an example of creating and displaying a df from the match
table.
match_id | tourn_id | consol_ind | team_id_1 | team_id_2 | maint_dtm | maint_app | create_dtm | create_app | |
---|---|---|---|---|---|---|---|---|---|
0 | M1 | T1 | N | T1 | T2 | 2022-04-09 03:19:33.840951+00:00 | postgres | 2022-04-09 03:19:33.840951+00:00 | postgres |
1 | M2 | T2 | N | T2 | T3 | 2022-05-26 00:45:11.301752+00:00 | postgres | 2022-05-26 00:45:11.301752+00:00 | postgres |
2 | M5 | T5 | N | T6 | T5 | 2022-06-28 00:40:22.948360+00:00 | postgres | 2022-06-28 00:40:22.948360+00:00 | postgres |
3 | M6 | T6 | N | T5 | T7 | 2022-07-07 23:01:45.921540+00:00 | postgres | 2022-07-07 23:01:45.921540+00:00 | postgres |
4 | M7 | T7 | N | T8 | T9 | 2022-07-11 02:40:50.597016+00:00 | postgres | 2022-07-11 02:40:50.597016+00:00 | postgres |
database_tables_to_csv ()
Saves the dataframes to csv files
Again, database_tables_to_csv
is only needed when the database itself is updated. You will likely not need to use this function