When performing technical analysis with the Intrinio Python SDK it's often helpful to convert the results of an API response into a Pandas DataFrame. 

If you've tried to do this with the documented properties of our API response objects you've probably run into some difficulties. 

for example:

...

api_response = security_api.get_security_stock_prices(
  identifier, start_date=start_date, end_date=end_date)

data_frame = pd.DataFrame(api_response.stock_prices)


results in:

0  {'adj_close': 147.626855036855,\n 'adj_high': ...
1  {'adj_close': 141.582776997777,\n 'adj_high': ...
2  {'adj_close': 157.245601965602,\n 'adj_high': ...


...which is not particularly useful.

Good news! There are dictionary-formatted versions of each documented property available on the API response object which play nicely with Pandas. Simply add an '_dict' to the property name.

for example:

...
api_response = security_api.get_security_stock_prices(
  identifier, start_date=start_date, end_date=end_date)

data_frame = pd.DataFrame(api_response.stock_prices_dict)


results in:

    adj_close    adj_high     adj_low ...
0  147.626855  147.915517  143.185901 ...
1  141.582777  145.097702  141.393588 ...
2  157.245602  158.171630  153.571360 ...


Bingo!

 

Did this answer your question?