question

Karel_S avatar image
0 Likes"
Karel_S asked ·

Screen_securities to pd.Dataframe, Python

Hi!
I am trying to extract companies by sic codes and market cap.
The output works fine as long as I treat it only as a list but I cannot figure out the property_name for (api_response.property_name_dict) to get it to pandas. I used pretty much every combination of the method name I could think of but ot no avail.

Any ideas/suggestions ?

below are the clauses (the x is part of a for loop)

clause1 = intrinio_sdk.SecurityScreenClause(
    field='sic',
    operator='eq',
    value= x
)
clause2 = intrinio_sdk.SecurityScreenClause(
    field='marketcap',
    operator='gt',
    value=1000
)
logic = intrinio_sdk.SecurityScreenGroup(operator="AND",
                                         clauses=[clause1, clause2])


Thank you!


screen securities
10 |600 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

· Write an Answer
Karel_S avatar image
0 Likes"
Karel_S answered ·

I believe I have found a solution. It is clunky, not very efficient and any knowledgable programmer would break my fingers for it, but it gets the job done for my specific case.

(I.) I need to extract tickers of companies that have a certain sic code
(II.) I feed the api a list of sic codes, clauses as above
(III.) Code - screen_securities does not seem to provide direct output to pandas, so this is my approach
note1: ticker for companies is in the last 8 characters, the loop below extracts some non-alphanum. characters, hence the regex.

note2: if dataa.empty = not all sic codes have companies associated with them in intrinio database.
Output = tickers of companies I want to get

paraf = []
dataa = pd.DataFrame.from_dict(api_response)
if dataa.empty:
    continue
for x in range(len(dataa)):
    ticker = str(dataa.loc[x, 0])[-8:]
    pattern = [r'\w+']
    for p in pattern:
        match = re.findall(p, ticker)
        paraf.append(match)
· Share
10 |600 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.