JECSand / yahoofinancials

A powerful financial data module used for pulling data from Yahoo Finance. This module can pull fundamental and technical data for stocks, indexes, currencies, cryptos, ETFs, Mutual Funds, U.S. Treasuries, and commodity futures.
https://pypi.python.org/pypi/yahoofinancials
MIT License
911 stars 215 forks source link

Returned JSON difficult to parse #36

Closed analystguy closed 5 years ago

analystguy commented 5 years ago

First - thanks for the great tools. I am rather new to Python and am having difficulty parsing the returned json into a dataframe. Is there a plan in the works to do so or can anyone offer assistance? The json returned appears as one long unstructured dictionary string.

sylvandb commented 5 years ago

Isn't the returned data a dict or maybe a list of dict? if you print(value) it will convert whatever it is into a string

you can experiment interactively with python, and try type(value)

alternatively, if somehow you do have a string containing json data then:

import json
value = json.loads(string_value)
sabirjana commented 5 years ago

Hello, great work!! Is there an easy way to get data in pandas dataframe from various supported methods ? Thanks

JECSand commented 5 years ago

Hi analystguy,

Here is an example I posted showing how to use YahooFinancials with Pandas.

https://github.com/JECSand/pandas_sqlalchemy_technical_analysis/blob/master/pandas_with_sqlalchemy.py

Thanks!