0

I am trying to import a pd_DF to SQL using a file.ipynb but it throws an error. If I try the same in a file.py it does work...

The error appears in the next line:

df2_imputed.to_sql('BBM_DATA', con=engine, index=False, if_exists= 'replace')

The error is:

'AttributeError: 'NoneType' object has no attribute 'replace''

At first, I thought it might be the NaN values inside de DF, but the DF has no NAN values now...

Can someone please help? Is it possible to work with SQL in .ipynb files ?

Thanks!

Parfait
  • 104,375
  • 17
  • 94
  • 125
  • 1
    https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_sql.html I have it working to a SQLite db. Could you share more of your code to see what the error is? – Paul Brennan Jan 01 '21 at 19:04
  • Yes, to_sql does work in ipynb files. I've used it. – Nick ODell Jan 02 '21 at 00:43
  • If same code with same data does not work in Jupyter notebook (.ipynb) and regular script (.py), then issue must be environment: different Python version or pandas version, etc. Please compare versions of [compiler](https://stackoverflow.com/q/1093322/1422451) and pandas/sqlalchemy versions and report back (do not assume anything). – Parfait Jan 02 '21 at 00:46

0 Answers0