title: Python pandas json_normalize how to
body: <p>I'm trying to create an API to get historical data from poloniex for my neuralnetwork to learn on for a school project.</p>
  
  <p>I get a json file back but the problem is that the poloinex_df is "empty", all the information is in the index/columnnames row (pic realated, variable explorer), I tried to transpose it somehow, then I have been told here, that panda has a function for this. I read the documentation, and looked around here for anserws, but didn't quite found what i was looking for. i would like to make a dataframes with indexes like dates open close volumne etc. and the corresponding data. How do I do that? Right now I get the error:</p>
  
  <pre><code>data_frame = json_normalize(poloinex_df, 'date' ,['high', 'low', 'open', 'close','volume','quoteVolume','weightedAverage'])
  </code></pre>
  
  <blockquote>
    <p>Traceback (most recent call last):</p>
    
    <p>File "", line 1, in 
        data_frame = json_normalize(poloinex_df, 'date' ,['high', 'low', 'open', 'close','volume','quoteVolume','weightedAverage'])</p>
    
    <p>File "C:\ToolBox\Anaconda2\lib\site-packages\pandas\io\json.py",
    line 761, in json_normalize
        _recursive_extract(data, record_path, {}, level=0)</p>
    
    <p>File "C:\ToolBox\Anaconda2\lib\site-packages\pandas\io\json.py",
    line 747, in _recursive_extract
        recs = _pull_field(obj, path[0])</p>
    
    <p>File "C:\ToolBox\Anaconda2\lib\site-packages\pandas\io\json.py",
    line 698, in _pull_field
        result = result[spec]</p>
    
    <p>TypeError: string indices must be integers, not str</p>
  </blockquote>
  
  <p>Pic in variable explorer from downloaded data:</p>
  
  <p><a href="https://i.stack.imgur.com/FtgJ9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FtgJ9.jpg" alt="enter image description here"></a></p>
  
  <p>I have to following code:</p>
  
  <pre><code>import chainer as chain
  import pandas as pd
  import numpy as np
  from matplotlib import pylab
  from pandas.io.json import json_normalize
  
  def get_poloinex_data(s, a, b, c):
  
      import requests
      from pandas import DataFrame
      from io import StringIO
  
      url = 'https://poloniex.com/public?command=returnChartData'
  
      url += '&amp;currencyPair=' + s #USDT for USD
      url += '&amp;start=' + a
      url += '&amp;end=' + b
      url += '&amp;period=' + c
  
      csv = requests.get(url)
  
      if csv.ok:
          return DataFrame.from_csv(StringIO(csv.text), sep=',') #Separator here
      else:
          return None
  
  params = {
      # specify stock
      "s": 'USDT_ETH',   # BTC_ETH, USDT_ETH stb
  
      # query data from
      'a': '1422230400',     # unix date stamp, 2015 jan 26 : 1422230400
  
      # query until
      'b': '1492905600',     # unix dates tamp, 2016 sep 23 : 1492905600
  
      # frequency
      'c': '14400'      # unix time stamp
  }
  
  
  poloinex_df = get_poloinex_data(**params)
  data_frame = json_normalize(poloinex_df, 'date' ,['high', 'low', 'open', 'close','volume','quoteVolume','weightedAverage'])
  #data_frame = json_normalize(poloinex_df.json())
  #TransposedData = poloinex_df.transpose()
  #data_frame = json_normalize(resp.json())
  </code></pre>
  
  <p>Thank you for your help and insight</p>