How to access information from polygon.entity.Exchange

Using api.polygon.exchanges(), I get a list of alpaca_trade_api.polygon.entity.Exchange. It appears they are Python dictionaries, but wrapped by Exchange().

I am not sure how to access them. Any suggestions? Thanks.

1 Like

All Entity-based class have _raw property that holds the raw json. But you can access field just by exchanges[0].mic which is more friendly.

Thanks for the reply.

What should I do if I want to convert the entire list into a pandas dataframe? Like with quotes data, I can add a .df at the end of each call.

Should I use a for loop, or there is a faster way?

1 Like

I believe pandas handles json/dict very well. Something like

df = pd.Dataframe(obj._raw)

Should convert it to a dataframe if the object is an array of something.