Last active
December 20, 2016 14:22
-
-
Save dobrych/6081e9da4a8666c3ec9c57c824233543 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
full_data_dict = dict() | |
for frame in fetch_batch(): | |
for layer in frame['entries']: # single batch can contain more than one timestamp | |
layer_coords = dict() | |
# convert lists of axes into dict | |
for layer_coord in layer['indexAxes']: | |
layer_coords[layer_coord[0]] = layer_coord[1] | |
# latitude and longitude should be present in the axes output | |
# otherwise it's an API error | |
assert 'latitude' in layer_coords | |
assert 'longitude' in layer_coords | |
data_layer_per_timestamp = pd.DataFrame( | |
layer['data'][VARIABLE], | |
index=layer_coords['latitude'], | |
columns=layer_coords['longitude'] | |
) | |
# group data frames by timestamp | |
full_data_dict[layer['axes']['time']] = data_layer_per_timestamp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment