I wrote a script to make updates to a Synapse table that fails when I go to push my changes back to Synapse. In broad strokes, the script pulls down a subset of records from a Synapse table, moves the values associated with the variable 'individualID' into a variable called 'projid', and then repopulates 'individualID' with a new set of identifiers that are merged in from a different Synapse entity. Then the updated rows are then pushed back to Synapse. Full code is here.
Here's the error I got:
Traceback (most recent call last):
File "update_rosmap_ids.py", line 55, in <module>
rosmap_updated_ids_df = syn.store(synapseclient.Table(rosmap_sm_table.tableId, rosmap_updated_ids_df))
File "/usr/local/lib/python3.7/site-packages/synapseclient/table.py", line 1287, in Table
return CsvFileTable.from_data_frame(schema, values, **kwargs)
File "/usr/local/lib/python3.7/site-packages/synapseclient/table.py", line 1637, in from_data_frame
cols = as_table_columns(df)
File "/usr/local/lib/python3.7/site-packages/synapseclient/table.py", line 439, in as_table_columns
maxStrLen = df[col].str.len().max()
File "/usr/local/lib64/python3.7/site-packages/pandas/core/generic.py", line 5175, in _getattr_
return object._getattribute_(self, name)
File "/usr/local/lib64/python3.7/site-packages/pandas/core/accessor.py", line 175, in _get_
accessor_obj = self._accessor(obj)
File "/usr/local/lib64/python3.7/site-packages/pandas/core/strings.py", line 1917, in _init_
self._inferred_dtype = self._validate(data)
File "/usr/local/lib64/python3.7/site-packages/pandas/core/strings.py", line 1967, in _validate
raise AttributeError("Can only use .str accessor with string " "values!")
AttributeError: Can only use .str accessor with string values!
For troubleshooting, I tried running with different datatypes of one of the columns I changed (casting 'projid' as float and object) and with different options for how missing values were represented in the other columns (Nan, None, '') – the same error persisted across all of these.
kindly also helped me troubleshoot.... and it worked fine on his machine, which was running the same version of Python (3.7.4) and the Python client (1.9.2) but Pandas 0.24.1.
Scicomp with Python 3.7.4, Pandas 0.25.1
> it worked fine on his machine, which was running the same version of Python (3.7.4) and the Python client (1.9.2) but Pandas 0.24.1
Sorry for the delayed reply. What version of Pandas do you use and have you tried using the same version as ? If so, what was the outcome?
Sorry for the slow reply on my end, too. I was running 0.25.1. The script/task I initially asked about wasn’t something I could rerun. Happily(?), I was doing something similar today and ran into the same problem. Downgrading to 0.24.1 fixed it.
I ran into the same issue today when using Pandas 0.25.1. The issue was resolved once I switched to an older version (0.20.0).
Could you have a look?