Data
¶
YFPY module for retrieving, saving, and loading all Yahoo Fantasy Sports data.
This module is designed to allow for easy data management, such that both retrieving and managing Yahoo Fantasy Sports data can be done in one place without the need to manually run the queries and manage data saved to JSON files.
Example
The Data module can be used as follows::
yahoo_query = YahooFantasySportsQuery(
"<league_id>",
"<game_code>",
game_id="<game_key>",
yahoo_consumer_key=os.environ.get("YFPY_CONSUMER_KEY"),
yahoo_consumer_secret=os.environ.get("YFPY_CONSUMER_SECRET"),
all_output_as_json_str=False,
browser_callback=True,
offline=False
)
data_directory = Path(__file__).parent / "output"
data = Data(data_dir)
data.save("file_name", yahoo_query.get_all_yahoo_fantasy_game_keys)
data.load("file_name")
Attributes: |
|
---|
Classes:
Name | Description |
---|---|
Data |
YFPY Data object for Yahoo Fantasy Sports data retrieval, saving, and loading data as JSON. |
Data ¶
Bases: object
YFPY Data object for Yahoo Fantasy Sports data retrieval, saving, and loading data as JSON.
Methods:
Name | Description |
---|---|
__init__ |
Instantiate data object to retrieve, save, and load Yahoo Fantasy Sports data. |
update_data_dir |
Modify the data storage directory if it needs to be updated. |
fetch |
Run query to retrieve Yahoo Fantasy Sports data. |
save |
Retrieve and save Yahoo Fantasy Sports data locally. |
load |
Load Yahoo Fantasy Sports data already stored locally. |
retrieve |
Fetch data from the web or load it locally (combination of the save and load methods). |
Source code in yfpy/data.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 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 |
|
__init__ ¶
__init__(data_dir, save_data=False, dev_offline=False)
Instantiate data object to retrieve, save, and load Yahoo Fantasy Sports data.
Parameters: |
|
---|
Source code in yfpy/data.py
54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
update_data_dir ¶
update_data_dir(new_save_dir)
Modify the data storage directory if it needs to be updated.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/data.py
68 69 70 71 72 73 74 75 76 77 78 |
|
fetch
staticmethod
¶
fetch(yf_query, params=None)
Run query to retrieve Yahoo Fantasy Sports data.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/data.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
save ¶
save(file_name, yf_query, params=None, new_data_dir=None)
Retrieve and save Yahoo Fantasy Sports data locally.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/data.py
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 |
|
load ¶
load(
file_name,
data_type_class=None,
new_data_dir=None,
all_output_as_json_str=False,
)
Load Yahoo Fantasy Sports data already stored locally.
Note
This method will fail if the save
method has not been called previously.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/data.py
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 |
|
retrieve ¶
retrieve(
file_name,
yf_query,
params=None,
data_type_class=None,
new_data_dir=None,
)
Fetch data from the web or load it locally (combination of the save and load methods).
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/data.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|