0

I am using a Yahoo finance Python library to grab accounting financial data to do some basic analysis. All of the financial statement data comes in JSON format. I want the data to be in a tabular format as I typically see in a Python dataframe. Hello there are several wrappers around the data and I'm not sure how to remove those so that I can get my data into a simple columns and rows dataframe. Here is what the Python looks like:

{
   "incomeStatementHistory":{
      "F":[
         {
            "2019-12-31":{
               "researchDevelopment":"None",
               "effectOfAccountingCharges":"None",
               "incomeBeforeTax":-640000000,
               "minorityInterest":45000000,
               "netIncome":47000000,
               "sellingGeneralAdministrative":10218000000,
               "grossProfit":12876000000,
               "ebit":2658000000,
               "operatingIncome":2658000000,
               "otherOperatingExpenses":"None",
               "interestExpense":-1049000000,
               "extraordinaryItems":"None",

2 Answers 2

1

you don't have the full response so it's difficult to tell if this will be what you want

d = {
   "incomeStatementHistory":{
      "F":[
         {
            "2019-12-31":{
               "researchDevelopment":"None",
               "effectOfAccountingCharges":"None",
               "incomeBeforeTax":-640000000,
               "minorityInterest":45000000,
               "netIncome":47000000,
               "sellingGeneralAdministrative":10218000000,
               "grossProfit":12876000000,
               "ebit":2658000000,
               "operatingIncome":2658000000,
               "otherOperatingExpenses":"None",
               "interestExpense":-1049000000,
               "extraordinaryItems":"None",}}]}}


pd.json_normalize(d['incomeStatementHistory']['F'])

Output:

  2019-12-31.researchDevelopment 2019-12-31.effectOfAccountingCharges  2019-12-31.incomeBeforeTax  ...  2019-12-31.otherOperatingExpenses  2019-12-31.interestExpense  2019-12-31.extraordinaryItems
0                           None                                 None                  -640000000  ...                               None                 -1049000000                           None

[1 rows x 12 columns]
Sign up to request clarification or add additional context in comments.

Comments

1

You should use Pandas Here its a tutorial of how to do that with pandas

Also you could check this question

1 Comment

Thank you for the quick response. I read the first one and tried to implement it but I got this. I just keep getting everything in one long string as it is printed.Thank you. 0 balanceSheetHistory [{'2019-12-31': {'capitalSurplus': 22165000000...

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.