0

Here's the response I get from my stock data API provider:

    {'status': {'code': 0, 'message': ''},
 'data': {'symbol': 'ESHRAQ',
  'company': 'Eshraq properties Co.',
  'exchange': 'ABU_DHABI',
  'prices': {'columns': ['date', 'open', 'high', 'low', 'close', 'volume'],
   'values': [['2021-12-16T10:00:00Z', 0.39, 0.39, 0.39, 0.39, 4140513],
    ['2021-12-19T10:00:00Z', 0.0, 0.0, 0.35, 0.38, 19006953]]}}}

I need the results to be a simple Pandas dataframe with the following columns: date, company, open, high, low, close, volume.

1 Answer 1

2
d = your_json['data']
df = pd.DataFrame(d['prices']['values'], columns=d['prices']['columns']).assign(company=d['company'])

Output:

>>> df
                   date  open  high   low close    volume                company
0  2021-12-16T10:00:00Z  0.39  0.39  0.39  0.39   4140513  Eshraq properties Co.
1  2021-12-19T10:00:00Z  0.00  0.00  0.35  0.38  19006953  Eshraq properties Co.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.