yfpy.data.Data
- class Data(data_dir, save_data=False, dev_offline=False)[source]
Bases:
object
YFPY Data object for Yahoo Fantasy Sports data retrieval, saving, and loading data as JSON.
Instantiate data object to retrieve, save, and load Yahoo Fantasy Sports data.
- Parameters:
Methods
Run query to retrieve Yahoo Fantasy Sports data.
Load Yahoo Fantasy Sports data already stored locally.
Fetch data from the web or load it locally (combination of the save and load methods).
Retrieve and save Yahoo Fantasy Sports data locally.
Modify the data storage directory if it needs to be updated.
Attributes
YFO
- static fetch(yf_query, params=None)[source]
Run query to retrieve Yahoo Fantasy Sports data.
- Parameters:
yf_query (Callable of YahooFantasySportsQuery) – Chosen yfpy query method to run.
str (params (dict of) – str, optional): Dictionary of parameters to be passed to chosen yfpy query function.
- Returns:
Data retrieved by the yfpy query.
- Return type:
- load(file_name, data_type_class=None, new_data_dir=None, all_output_as_json_str=False)[source]
Load Yahoo Fantasy Sports data already stored locally.
Note
This method will fail if the save method has not been called previously.
- Parameters:
file_name (str) – Name of file from which data will be loaded.
data_type_class (Type[YahooFantasyObject], optional) – YFPY models.py class for data casting.
new_data_dir (str | Path, optional) – Full path to new desired directory from which data will be loaded.
all_output_as_json_str (bool) – Boolean indicating if the output has been requested as a raw JSON string.
- Returns:
Data loaded from the selected JSON file.
- Return type:
- retrieve(file_name, yf_query, params=None, data_type_class=None, new_data_dir=None)[source]
Fetch data from the web or load it locally (combination of the save and load methods).
- Parameters:
file_name (str) – Name of file to/from which data will be saved/loaded.
yf_query (Callable of YahooFantasySportsQuery) – Chosen yfpy query method to run.
str (params (dict of) – str, optional): Dictionary of parameters to be passed to chosen yfpy query function.
data_type_class (Type[YahooFantasyObject], optional) – YFPY models.py class for data casting.
new_data_dir (str | Path, optional) – Full path to new desired directory to/from which data will be saved/loaded.
- Returns:
Data retrieved by the yfpy query OR loaded from the selected JSON file.
- Return type:
- save(file_name, yf_query, params=None, new_data_dir=None)[source]
Retrieve and save Yahoo Fantasy Sports data locally.
- Parameters:
file_name (str) – Name of file to which data will be saved.
yf_query (Callable of YahooFantasySportsQuery) – Chosen yfpy query method to run.
str (params (dict of) – str, optional): Dictionary of parameters to be passed to chosen yfpy query function.
new_data_dir (str | Path, optional) – Full path to new desired directory to which data will be saved.
- Returns:
Data retrieved by the yfpy query.
- Return type: