There is a value that the user writes (I can not know in advance what it will be), for example, take three values 123 , з , о . I need to put them in one column in the excel file. But the problem is that when the user enters the values, everything is placed not in the column but simply replaces each other. Ie, first entered 123 is put in the line at number 0 : number 0

But when the second value is entered, namely, it is not placed in the line number 1, but in the line number 0, that is, they replace each other and the same value with the third value. Thanks in advance for the answers.

  • Specify how you create the DataFrame ... - MaxU
  • @MaxU df = pandas.DataFrame({'Date': [mes]}) . Mes is what the user sends - LoPi
  • mes is a list of values ​​or one value? The question is formulated incomprehensibly - what should be written in excel-file - one column or several? - MaxU
  • @MaxU mes is a list of values ​​that I cannot know in advance (because the user enters it). And all the values ​​that the user enters must be written in the column. The first value is placed where necessary (at the very top), but it does not enter subsequent values ​​on a new line. And on the same as the first value, that is, it simply erases the first value and its place puts the second value. - LoPi

1 answer 1

First, accumulate all the values ​​entered by the user into one list and create a DataFrame from this list:

 import pandas as pd # предположим пользователь ввел: mes = [123, 'з', 'o'] df = pd.DataFrame({'Date': mes}) # запись в Excel file: df.to_excel(r'c:/temp/a.xlsx', index=False) 

Result:

enter image description here