Skip to content

Instantly share code, notes, and snippets.

@systemcatch
Last active October 2, 2018 15:33
Show Gist options
  • Save systemcatch/019cf50302093b9b51838c62b99623df to your computer and use it in GitHub Desktop.
Save systemcatch/019cf50302093b9b51838c62b99623df to your computer and use it in GitHub Desktop.
A variety of examples for eiapy
# Find 5 years of data for Federal oil & gas production in the Gulf of Mexico.
gulf_category = Category(296728).get_info()
# Find all child series and make a list of them.
gulf_childseries = gulf_category['category']['childseries']
gulf_series_ids = [i['series_id'] for i in gulf_childseries]
data = MultiSeries(gulf_series_ids).last(5)
{'request': {'command': 'series',
'series_id': 'PET.RCRR10R3FM_1.A;PET.RCRR71R3FM_1.A;PET.RCRR72R3FM_1.A;PET.RCRR73R3FM_4.A;PET.RL2R10R3FM_1.A;PET.RL2R57R3FM_1.A;PET.RL2R71R3FM_1.A;PET.RL2R72R3FM_1.A;PET.RL2R73R3FM_4.A;PET.RL2R9901R3FM_1.A;PET.RL2R9902R3FM_4.A;PET.RL2R99R3FM_1.A;PET.RNGR20R3FM_1.A;PET.RNGR30R3FM_1.A;PET.RNGR78R3FM_1.A;PET.RNGR79R3FM_1.A;PET.RNGR80R3FM_4.A;PET.RNGR86R3FM_1.A;PET.RNGR87R3FM_1.A;PET.RNGR88R3FM_4.A'},
'series': [{'copyright': 'None',
'data': [['2007', 414],
['2006', 406],
['2005', 409],
['2004', 467],
['2003', 485]],
'description': 'Gulf of Mexico Federal Offshore Crude Oil '
'Production',
'end': '2007',
'f': 'A',
'name': 'Gulf of Mexico Federal Offshore Crude Oil Production, '
'Annual',
'series_id': 'PET.RCRR10R3FM_1.A',
'source': 'EIA, U.S. Energy Information Administration',
'start': '1992',
'units': 'Million Barrels',
'unitsshort': 'MMbbl',
'updated': '2014-10-16T15:14:01-0400'},
{'copyright': 'None',
'data': [['2007', 313],
['2006', 318],
['2005', 305],
['2004', 310],
['2003', 336]],
'description': 'Gulf of Mexico Federal Offshore Crude Oil '
'Production from Greater than 200 Meters Deep',
'end': '2007',
'f': 'A',
'name': 'Gulf of Mexico Federal Offshore Crude Oil Production '
'from Greater than 200 Meters Deep, Annual',
'series_id': 'PET.RCRR71R3FM_1.A',
'source': 'EIA, U.S. Energy Information Administration',
'start': '1992',
'units': 'Million Barrels',
'unitsshort': 'MMbbl',
'updated': '2014-10-16T15:14:01-0400'}, # snipped for readability
##############################################
# Check electrical demand in New York on the 4th of July, Thanksgiving & Christmas in the evening.
demand_by_hour = Series('EBA.NYIS-ALL.D.H')
# just return the data
indep = demand_by_hour.get_data(start='20170704T17Z', end='20170704T23Z')['series'][0]['data']
thanks = demand_by_hour.get_data(start='20171123T17Z', end='20171123T23Z')['series'][0]['data']
xmas = demand_by_hour.get_data(start='20171225T17Z', end='20171225T23Z')['series'][0]['data']
([['20170704T23Z', 21792],
['20170704T22Z', 22007],
['20170704T21Z', 22004],
['20170704T20Z', 21754],
['20170704T19Z', 21403],
['20170704T18Z', 21009],
['20170704T17Z', 20601]],
[['20171123T23Z', 17006],
['20171123T22Z', 16702],
['20171123T21Z', 16459],
['20171123T20Z', 16637],
['20171123T19Z', 16949],
['20171123T18Z', 17258],
['20171123T17Z', 17354]],
[['20171225T23Z', 19076],
['20171225T22Z', 18193],
['20171225T21Z', 17513],
['20171225T20Z', 17379],
['20171225T19Z', 17382],
['20171225T18Z', 17532],
['20171225T17Z', 17526]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment