Store.ipynb - Colab
Store.ipynb - Colab
ipynb - Colab
import pandas as pd
df=pd.DataFrame([[11,21,31],[1,22,32],[315,32,33]],
index=['one','two','three'],columns=['a','b','c'])
print(df)
a b c
one 11 21 31
two 1 22 32
three 315 32 33
print("Taking the input from Dataframe and storing in the Excel file")
df.to_excel("/content/pandas to excel.xlsx", sheet_name='pandas to excel')
b=pd.read_excel("/content/pandas to excel.xlsx")
print(b)
Taking the input from Dataframe and storing in the Excel file
Unnamed: 0 a b c
0 one 11 21 31
1 two 1 22 32
2 three 315 32 33
d=pd.DataFrame([[110,210,310],[12,220,320],[310,320,330]],
index=['four','five','six'],columns=['a','b','c'])
d.to_excel("/content/pandas to excel2.xlsx",sheet_name='pandas to excel')
z=pd.read_excel("/content/pandas to excel2.xlsx")
print(z)
Unnamed: 0 a b c
0 four 110 210 310
1 five 12 220 320
2 six 310 320 330
x=pd.read_excel("/content/pandas to excel.xlsx")
y=pd.read_excel("/content/pandas to excel.xlsx")
z=pd.concat([x, y], ignore_index=True) # Use pd.concat instead of append
z.to_excel('/content/pandas to excel3.xlsx', index=False) #Avoid saving the index
b=pd.read_excel("/content/pandas to excel3.xlsx")
print(b)
Unnamed: 0 a b c
0 one 11 21 31
1 two 1 22 32
2 three 315 32 33
3 one 11 21 31
4 two 1 22 32
5 three 315 32 33
df=z.sort_values(["a"])
print(df)
df.to_excel("/content/pandas to excel4.xlsx")
Unnamed: 0 a b c
1 two 1 22 32
https://colab.research.google.com/drive/11KmNNXLHtxLnRPQQIwGDjM7_c8lI1cLd#scrollTo=bh1aL1BcBB_n&printMode=true 1/3
2/14/25, 9:53 AM Store_149.ipynb - Colab
4 two 1 22 32
0 one 11 21 31
3 one 11 21 31
2 three 315 32 33
5 three 315 32 33
Unnamed: 0.1 Unnamed: 0 a b c
0 1 two 1 22 32
1 4 two 1 22 32
2 0 one 11 21 31
3 3 one 11 21 31
4 2 three 315 32 33
5 5 three 315 32 33
df=pd.read_excel('/content/test.xlsx')
print(df)
print(list(df))
print(format(len(df)))
https://colab.research.google.com/drive/11KmNNXLHtxLnRPQQIwGDjM7_c8lI1cLd#scrollTo=bh1aL1BcBB_n&printMode=true 2/3
2/14/25, 9:53 AM Store_149.ipynb - Colab
https://colab.research.google.com/drive/11KmNNXLHtxLnRPQQIwGDjM7_c8lI1cLd#scrollTo=bh1aL1BcBB_n&printMode=true 3/3