Repository navigation
PydanticSerializationError: Unable to serialize unknown type: <class 'numpy.int64'> #694
Replies: 3 comments
|
Hi @Nevermetyou65 did you manage to solve it? I have the same issue even though mine is a list, it says numpy array. |
|
I ran into the same thing before. Pandas can leave Qdrant cannot serialize those types, so you need to cast before upload: import numpy as np
def to_py(v):
if isinstance(v, np.integer):
return int(v)
if isinstance(v, np.floating):
return float(v)
if isinstance(v, np.ndarray):
return v.tolist()
return v
payload = {k: to_py(v) for k, v in row.items() if k != "fn_vectors"}Also make sure your vector is a plain Python list, not a numpy array. |
|
@Nevermetyou65 a top-level dtype scan cannot see it. An
def to_builtin(o):
if isinstance(o, np.generic): return o.item()
if isinstance(o, np.ndarray): return o.tolist()
if isinstance(o, dict): return {k: to_builtin(v) for k, v in o.items()}
if isinstance(o, (list, tuple)): return [to_builtin(v) for v in o]
return o@thebirdgr yours is the |
Uh oh!
There was an error while loading. Please reload this page.
Hello
I tried to upload points to the collection
here is my code
My variable
tmp_dictis a list of dictionaries obtained from the pandas data frame with.to_dict(orient="records").I got this error
PydanticSerializationError: Unable to serialize unknown type: <class 'numpy.int64'>This is confusing because I have already checked the data type for my payload and vector. There is no
numpy.int64Need help with this
Thanks
All reactions