I am getting the following error for code I did not write. Not sure what this error is indicating. I've tried adding the 'Series' package but it keeps failing, but I'm not even sure if that's the problem here.
Error Message:
Traceback (most recent call last):
File "C:/Users/.../PycharmProjects/SocialActivityData/20181030_CE_SocialActivity_API_Call_manual (1).py", line 146, in <module>
For_df_accountType.append(r.get_values().tolist()[0]['accountType'])
File "C:\Users\\...\AppData\Local\Temp\20181030_CE_SocialActivity_API_Call_manual (1).py\venv\lib\site-packages\pandas\core\generic.py", line 5274, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'get_values'
Code it's referencing:
### looping through the nested attritutes column to flatten/normalize the column into a somple table with just the required columns
for i, r in df_DimensionsColumns.iterrows():
For_df_index.append(i)
For_df_accountType.append(r.get_values().tolist()[0]['accountType'])
try:
For_df_message.append(r.get_values().tolist()[0]['content']['message'])
except:
For_df_message.append('no message available from Sprinklr')
pass
try:
For_df_permalink.append(r.get_values().tolist()[0]['permalink'])
except:
For_df_permalink.append('no permalink available from Sprinklr')
pass
You need not 'add the series package' as it should be contained in what I assume you are using -- Pandas
If you check the documentation on Series
, you'll find that there is no method called get_values
which is what you're calling here:
For_df_accountType.append(r.get_values().tolist()[0]['accountType'])
# ^^ Right here
It could be that the script or program that you have found was leveraging an earlier version of Pandas, which is causing an issue because you're now using a newer version.
Here is the documentation on Series
: https://pandas.pydata.org/pandas-docs/stable/reference/series.html
You might try changing r.get_values().tolist()[0]['accountType']
to something to the effect of r.array[0]['accountType']
, or perhaps r.to_list()[0]['accountType']
(per here) but I can't guarantee that will work because I have no experience with Pandas.
The documentation is your best friend, really.