0

When I run the following code, it runs, however, the middle portion of data from row 5 to row 720 is missing. Where row 5 should appear, the row is filled with dots. See the following code and output:

import pandas as pd
import requests
from pandas.io.json import json_normalize
from config import client_id

stock = "GOOG"
endpoint = r'https://api.tdameritrade.com/v1/marketdata/{}/pricehistory'.format(stock)

payload = {'apikey':client_id,
       'periodType': 'day',
       'frequencyType': 'minute',
       'frequency' :'1',
       'period':'2',
       'needExtendedHoursData':'true'}

content = requests.get(url = endpoint, params = payload)
data = content.json()
df = pd.json_normalize(data['candles'])
print(df)
#print (data)   // If I run this line, it displays all the historical data unformatted.

Output:

          open       high      low    close  volume       datetime
0    2103.0000  2103.0000  2103.00  2103.00     119  1613045160000
1    2106.0000  2106.0000  2106.00  2106.00     118  1613051640000
2    2096.3300  2102.0000  2096.33  2098.04    1400  1613053680000
3    2099.2100  2099.2100  2099.16  2099.16     200  1613053740000
4    2099.1200  2102.0300  2085.62  2090.31   32575  1613053800000
..         ...        ...      ...      ...     ...            ...
721  2104.6500  2104.6500  2104.00  2104.00     200  1613167200000
722  2104.9900  2104.9900  2104.99  2104.99     300  1613167500000
723  2104.9900  2104.9900  2104.99  2104.99     195  1613167560000
724  2105.9999  2105.9999  2104.99  2104.99    2200  1613167740000
725  2104.1100  2104.1100  2104.11  2104.11    2810  1613167920000

[726 rows x 6 columns]

Could someone point me in the right direction to resolve this issue?

The above code was obtained from How to extract json from nested column to dataframe.

ad absurdum
  • 19,498
  • 5
  • 37
  • 60
Yowzet
  • 1
  • 1
  • 1
    This was answered here: https://stackoverflow.com/a/30691921/11832127. – ndclt Feb 16 '21 at 19:54
  • 2
    Does this answer your question? [Pretty-print an entire Pandas Series / DataFrame](https://stackoverflow.com/questions/19124601/pretty-print-an-entire-pandas-series-dataframe) – ndclt Feb 16 '21 at 19:54

0 Answers0