Skip to content
Advertisement

empty column in .toexcel() with pandas

i use pandas for python to generate a xlsx file with two other file. i take the first one as a template, and file the column with the second file. i wrote:

JavaScript

but when i open my xlsx file the column ” and ‘Code du client *’ are empty, the other Columns are OK… I don’t know why it doesn’t run for the two first column…

Advertisement

Answer

The code is assigning constant values to columns, not setting the values of a new row. The syntax :

JavaScript

Tries to set the value to all items in the Series. If that series is empty (as is the case here) nothing is set.

On the other hand, df_complete['Raison sociale *']=df_client['Nom_Entreprise'].str.upper() copies data from another dataframe that does contain some data.

To demonstrate :

JavaScript

Produces

JavaScript

Adding another series with values, only fills that series:

JavaScript

At the very least, rows should be added before setting series values:

JavaScript
Advertisement