I am trying to write from a pandas dataframe to AWS redshift:
df_tmp_rpt = pd.read_csv('path')
df_tmp_rpt = df_tmp_rpt[df_tmp_rpt['COL'] == 'VALUE']
df_tmp_rpt = df_tmp_rpt.replace(np.nan, null, regex=True)
records = df_tmp_rpt.to_records(index=False)
for record in records:
script_insert = ScriptReader.get_script(SCRIPT_PATH).format(record)
RedshiftDataManager.run_update(script_insert, DB_CONNECTION)
Redshift expects the format ('value1','value2',null) for inserting data. That is why i try to replace all NaN with null in the dataframe. How would I achieve such thing? (I need a null value not the string 'null')
Thanks for help in advance