Python Forum
Write from dictionary to excel
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write from dictionary to excel
#3
(Oct-10-2022, 10:18 PM)Am1n3 Wrote: Hi divon,
The answer to your request by using df.to_excel() method, which creates the excel file then writes your dataframe into it,
import numpy as np
import pandas as pd

n = 3
N = pow(2, n)

ilr_arr = np.zeros((n+1, N))
ilr_dict = dict()
df = pd.DataFrame
for idp in range(n + 1):
    a = pow(2, idp)
    b = pow(2, n - idp)
    ilr_dict[idp] = np.reshape(ilr_arr[idp], (a, b))
    for ing in range(a):
        interleaver = np.arange(pow(2, n - idp))
        np.random.shuffle(interleaver)
        ilr_dict[idp][ing] = interleaver
        df=pd.DataFrame(data=ilr_dict[idp])
print(df)
df.to_excel('saveMyOutput.xlsx')

Thank you very much for your reply, @Am1n3. It really helps me to proceed with my task. Big Grin
Reply


Messages In This Thread
Write from dictionary to excel - by divon - Sep-27-2022, 05:06 AM
RE: Write from dictionary to excel - by Am1n3 - Oct-10-2022, 10:18 PM
RE: Write from dictionary to excel - by divon - Jun-10-2023, 01:06 AM
RE: Write from dictionary to excel - by Larz60+ - Jun-11-2023, 10:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Split excel file and write output at specific row and set sheet position DSCA 0 2,041 May-12-2022, 07:29 PM
Last Post: DSCA
  Write a dictionary with arrays as values into JSON format paul18fr 3 5,813 Oct-20-2021, 10:38 AM
Last Post: buran
  [Pandas] Write data to Excel with dot decimals manonB 1 5,978 May-05-2021, 05:28 PM
Last Post: ibreeden
  Read exel with merged cells and write to another excel SriMekala 0 3,028 Aug-10-2019, 07:14 AM
Last Post: SriMekala
  how read and write merged cells in excel SriMekala 1 15,247 Aug-07-2019, 11:27 PM
Last Post: scidam
  Python write result of VAR to excel file wissam1974 8 8,807 Jul-13-2019, 01:09 PM
Last Post: wissam1974
  Pandas - Write to Exisitng Excel File - Sorted List dj99 4 15,067 Jul-29-2018, 07:56 AM
Last Post: dj99
  How do I write a line of code into an excel spreadsheet using Python code? Emerogork 2 3,262 Feb-07-2018, 06:54 PM
Last Post: snippsat
  Write data into existing Excel (xlsx) file with multiple sheets BNB 1 15,407 Jun-01-2017, 04:22 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020