import
zipfile
import
pandas as pd
data_frame1
=
pd.DataFrame({
'Fruits'
: [
'Appple'
,
'Banana'
,
'Mango'
,
'Dragon Fruit'
,
'Musk melon'
,
'grapes'
],
'Sales in kg'
: [
20
,
30
,
15
,
10
,
50
,
40
]})
data_frame2
=
pd.DataFrame({
'Vegetables'
: [
'tomato'
,
'Onion'
,
'ladies finger'
,
'beans'
,
'bedroot'
,
'carrot'
],
'Sales in kg'
: [
200
,
310
,
115
,
110
,
55
,
45
]})
data_frame3
=
pd.DataFrame({
'Baked Items'
: [
'Cakes'
,
'biscuits'
,
'muffins'
,
'Rusk'
,
'puffs'
,
'cupcakes'
],
'Sales in kg'
: [
120
,
130
,
159
,
310
,
150
,
140
]})
data_frame4
=
pd.DataFrame({
'Cool drinks'
: [
'Pepsi'
,
'Coca-cola'
,
'Fanta'
,
'Miranda'
,
'7up'
,
'Sprite'
],
'Sales in count'
: [
1209
,
1230
,
1359
,
3310
,
2150
,
1402
]})
with zipfile.ZipFile(
"path_to_file.zip"
,
"w"
) as zf:
with zf.
open
(
"filename.xlsx"
,
"w"
) as
buffer
:
with pd.ExcelWriter(
buffer
) as writer:
data_frame1.to_excel(writer, sheet_name
=
"Fruits"
, index
=
False
)
data_frame2.to_excel(writer, sheet_name
=
"Vegetables"
, index
=
False
)
data_frame3.to_excel(writer, sheet_name
=
"Baked Items"
, index
=
False
)
data_frame4.to_excel(writer, sheet_name
=
"Cool Drinks"
, index
=
False
)