Versions where problem occurs:
python 3.6.13
pandas 1.1.5
numpy 1.19.2
This seems trivial but I can't find a satifying solultion so far. First, I import data into a pandas Dataframe before loading to an SQL database. The failure message that I've gotten is:
ProgrammingError: (pyodbc.ProgrammingError) ('Invalid parameter type. param-index=0 param-type=numpy.int64', 'HY105')
Apparently, to get the dataframe into the database, the dtype can't be numpy.int64 and must be int. I had found a solution here: "Invalid parameter type" (numpy.int64) when inserting rows with executemany()
Here is a screenshot of the target column dtype:
The only way I've found to get data to be dtype int is the native function int(), but that can be only used on singular values.
The numpy method .astype(int) for some reason only converts to numpy.int32:
df = pd.DataFrame(data=[[1,4,5], [2, 'nan', 4]], columns=['A', 'B', 'C'])
df[['A', 'C']] = df[['A', 'C']].astype(int)
df.info()
Both the .info() method, as well as checking the type of individual values yields int32 for me.
Can someone please tell me how to turn the whole dataframe into native int that way I can import into my database??