You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "<stdin>", line 9, in <module>
File "/opt/conda/lib/python3.6/site-packages/gastrodon/__init__.py", line 502, in select
frame=self._dataframe(result)
File "/opt/conda/lib/python3.6/site-packages/gastrodon/__init__.py", line 397, in _dataframe
column[key] = self._normalize_column_type(column[key])
File "/opt/conda/lib/python3.6/site-packages/gastrodon/__init__.py", line 376, in _normalize_column_type
return [None if x==None else int(x) for x in column]
File "/opt/conda/lib/python3.6/site-packages/gastrodon/__init__.py", line 376, in <listcomp>
return [None if x==None else int(x) for x in column]
TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.date'
I believe that they are coming from _normalize_column_type:
pd.datetime is not considered, so when trying to do int(x) where x is a pd.datetime, the above error appears.
If all elements in the column are float type, they are silently casted into int, as shown in the issue above.
My question now is: is it really necessary to normalize the columns? pandas is usually smart enough to accommodate column types and cast if needed.
If I skip the _normalize_column_type() in the code, in the previous issue with the stars example, the mass is not casted to int, and if needed to cast to str, it does:
After playing around a bit with gastrodon, I think I have bumped into some problems regarding column types. To reproduce:
Preliminaries
Error with dates
Output:
Issue (casting floats)
Output:
Expected output:
(see this)
Possible cause
I believe that they are coming from
_normalize_column_type
:pd.datetime
is not considered, so when trying to doint(x)
wherex
is apd.datetime
, the above error appears.float
type, they are silently casted intoint
, as shown in the issue above.My question now is: is it really necessary to normalize the columns?
pandas
is usually smart enough to accommodate column types and cast if needed.If I skip the
_normalize_column_type()
in the code, in the previous issue with the stars example, the mass is not casted toint
, and if needed to cast tostr
, it does:Output:
The text was updated successfully, but these errors were encountered: