19 lines
478 B
Python
19 lines
478 B
Python
#!/usr/bin/env python3
|
|
import xlwings as xw
|
|
import pandas as pd
|
|
|
|
wb = xw.Book() # this will open a new workbook
|
|
wb = xw.Book('FileName.xlsx') # connect to a file that is open or in the current working directory
|
|
sheet = wb.sheets['Sheet1']
|
|
|
|
|
|
df = pd.DataFrame([[1,2], [3,4]], columns=['a', 'b'])
|
|
sheet['A1'].value = df
|
|
sheet['A1'].options(pd.DataFrame, expand='table').value
|
|
|
|
|
|
@xw.func
|
|
@xw.arg('x', pd.DataFrame)
|
|
def correl2(x):
|
|
# x arrives as DataFrame
|
|
return x.corr() |