Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

df.av.listed() causes subsequent API calls to fail with *** AttributeError: 'str' object has no attribute 'name' #11

Open
rterbush opened this issue Jul 3, 2023 · 1 comment

Comments

@rterbush
Copy link

rterbush commented Jul 3, 2023

To reproduce this, do the following:

df = pd.DataFrame()

listed_df = df.av.listed()

hist_df = df.av.daily(symbol='MSFT')

If you call listed() after any other API call it works as expected but any API call after the listed() method will fail with

*** AttributeError: 'str' object has no attribute 'name'

This appears to be due to the name column that exists in the listed() output. It is possible that this might be fixed by renaming that column to something like company? I've not dug any deeper into this.

@madeupname
Copy link

Run into the same problem. Tracing with the debugger, the problem starts with the fact certain AV REST API functions only return a CSV. When you use them in this library, it appears to change the default json to csv. When that happens, the results are not converted to a DataFrame, but returned as text (in violation of the specified typing of the function).

The problem is that all this is done via an internal, module level variable called AV in _extension.py. The bigger problem is that datatype is the one field not listed as a property, so you can't modify it after calling a CSV-only method. I can't find a way to get around this (nor can Copilot).

The only viable way to handle this (that I can see) is to use the class approach that allows you to create a new instance with new state. It's a shame because the DataFrame extension offers a very nice DX.

Curious if you found another approach/workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants