I have an EXCEL table that I want to transfer into a dataframe matching our project's standard with 22 different columns. The original EXCEL table, however, only has 13 columns, so I am trying to add the missing ones to the dataframe I have read from the file.
However, this has caused several challenges:
- When assigning an empty list - []to the dataframe, I get the notification that the size of the added columns does not match the original dataframe, which has circa 9000 rows.
- When assigning - np.nanto the dataframe, creating the joint dataframe with all required columns works perfectly:
f_unique.loc[:, "additional_info"] = np.nan
But having np.nan in my data causes issues later in my script when I flatten the cell data as all other cells contain lists.
So I have tried to replace np.nan by a list containing the string "n/a":
grouped_df = grouped_df.replace(np.nan, ["n/a"])
However, this gives me the following error:
TypeError: Invalid "to_replace" type: 'float'
Is there a way in which I can assign 9000 x ["n/a"] to each new column in my dataframe directly? That would most likely solve the issue.
 
     
    