First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
The pandas dataframes looks OK. Make sure that "path", Excel_file" are defined and pandas import works.
Define sid before calling 'abusint' and similar functions. Set sid=-1 for all buses.
Using 'savnw.sav' and engine set to xlsxwriter, I got an xlsx file output:
#writer = pd.ExcelWriter(filename, engine='openpyxl')
writer = pd.ExcelWriter(filename, engine='xlsxwriter')
#wb = writer.book
df_nodes.to_excel(writer, sheet_name = 'NODES')
df_branches.to_excel(writer, sheet_name = 'BRANCHES')
#wb.save(filename)
writer.save()
2 | No.2 Revision |
The pandas dataframes looks OK. Make sure that "path", Excel_file" are defined and pandas import works.
Define sid before calling 'abusint' and similar functions. Set sid=-1 for all buses.
Using 'savnw.sav' and engine set to xlsxwriter, I got an xlsx file output:
#writer = pd.ExcelWriter(filename, engine='openpyxl')
writer = pd.ExcelWriter(filename, engine='xlsxwriter')
#wb = writer.book
df_nodes.to_excel(writer, sheet_name = 'NODES')
df_branches.to_excel(writer, sheet_name = 'BRANCHES')
#wb.save(filename)
writer.save()
Another way is to use pandas' dataframe to_excel method:
# from https://www.geeksforgeeks.org/dataframe-to_excel-method-in-pandas/
import pandas as pd
# dictionary of data
dct = {'ID': {0: 23, 1: 43, 2: 12, 3: 13, 4: 67, 5: 89,
6: 90, 7: 56, 8: 34},
'Name': {0: 'Ram', 1: 'Deep', 2: 'Yash', 3: 'Aman',
4: 'Arjun', 5: 'Aditya', 6: 'Divya', 7: 'Chalsea', 8: 'Akash' },
'Marks': {0: 89, 1: 97, 2: 45, 3: 78,
4: 56, 5: 76, 6: 100, 7: 87, 8: 81},
'Grade': {0: 'B', 1: 'A', 2: 'F', 3: 'C', 4: 'E', 5: 'C', 6: 'A', 7: 'B', 8: 'B'}
}
# forming dataframe
data = pd.DataFrame(dct)
# storing into the excel file
data.to_excel("output.xlsx")