python yahooquery - extract modules / dict with lists

Hi all,

I have a Python simple script (see below) to extract financial data. The output is a mainly a dict format. However I want e.g. to get the #of analist which is part of the module “earningsTrend” (see picture 2). But also a lot of other metrics so I’m searching for an overall workable dataset

Via String Manupulation you can clean the string but that’s not so handy for so many metrics.

Can anyone give me some hints to get a “neat” dataset like this but included all the modules (for structure see picture 1)

picture 1

picture (2)

= = = =
#Copy input to output
#output_table_1 = input_table_1.copy()

import pandas as pd
from yahooquery import Ticker

funds = [‘aapl’, ‘amzn’]

ticker_def = Ticker(funds, asynchronous=True) # Make asynchronous requests

all = ticker_def.all_modules #asset_profile print(all)

all = pd.DataFrame.from_dict(all)
all = all.astype(str)

#all = all.iloc[0:1] # to select one or more rows

output_table_1 = all.copy()

= = = =

@sanderlenselink it seems this could be a job for a JSON or XML node. Maybe setting up a XPath definition of what you want to extract from the field.

Maybe give this node a try:


@mlauber71 . . . thnx for your great suggestion . . . it was some puzzling but I reached my goal!!!