I have the following code:
db_fields = ("id", "email", "status", "source")
df = DataFrame(results)
for col in db_fields:
if col not in df.columns:
COLUMN IS MISSING - COMMAND TO ADD COLUMN
If for example status
column is missing it needs to be added to the data frame with nothing as value so when I export the df
to csv
I will always have the same schema of fields.
I know that to remove column I should do:
df = df.drop(col, 1)
But I don't know what is the best way to add column with empty value.