I need to write two dataframe lists to a CSV in 2 rows, and in future i need add few more rows. I am using below, the first dataframe works fine sucessfully not the second one
import pandas as pd
df = pd.read_csv ("input.csv")
#From column name Test2 take count value of entry which is simple
simp = df.Test2.value_counts().Simple
medium = df.Test2.value_counts().Medium
list1 = [2, 5, 3, 3, 3]
list2 = [5, 10, 5, 5, 5]
#multiplying the above list value with the count of simple from input CSV
simplelist = [i * simp for i in list1]
mediumlist = [i * medium for i in list2]
print(simplelist)
print(mediumlist)
#[24, 60, 36, 36, 36]
#[60, 120, 60, 60, 60]
# till here its working. Its printing as expected
# I need to write the CSV with above value 1 to 5 from above list with Type as Simple and Medium
columns=['Type', 'Value1', 'Value2', 'Value3', 'Value4', 'Value5']
df1 = pd.DataFrame([['Simple'] + simplelist], columns=columns)
df2 = pd.DataFrame([['Medium'] + mediumlist], columns=columns)
# I can use below to add first row but df2, I am not sure how to add that the second dataframe df2. PLease help
df1.to_excel("output.xlsx")
It should as below for me.
Type Value1 Value2 Value3 Value4 Value5
Simple 24 60 36 36 36 (Working)
Medium 60 120 60 60 60 (Can not figure how to add this)
Please help, how can I add the second dataframe, please do needf