0% found this document useful (1 vote)
622 views19 pages

Xlwings and Excel

The document provides information about a presentation on the xlwings Python library for interacting with Excel. The presentation will cover how to use xlwings to: 1) Script and interact with Excel from Python 2) Create macros in Excel using Python 3) Define custom functions in Excel (UDFs) using Python

Uploaded by

Hoangdh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
622 views19 pages

Xlwings and Excel

The document provides information about a presentation on the xlwings Python library for interacting with Excel. The presentation will cover how to use xlwings to: 1) Script and interact with Excel from Python 2) Create macros in Excel using Python 3) Define custom functions in Excel (UDFs) using Python

Uploaded by

Hoangdh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

xlwings: Python & Excel

• For Python Quants Conference


• New York City

May 6th, 2016 Felix Zumstein


Material

• For the material presented during the


demos (Part 1 &3), see:
https://github.com/ZoomerAnalytics/xlwings_noteboo
ks/tree/master/for_python_quants_conference_nyc_2
0160506

2
About me

• Consultancy (Zurich):
– Analytical apps for Excel & web
– Open-source: xlwings

• Previously:
– 9yrs in Banking /Asset Management
– Background: Finance & Economics

3
The open-source Python/Excel Landscape

Reading/
Writing

Programming/
Interacting

4
xlwings Features

1 Scripting/Interaction

2 Macros

3 User Defined Functions (UDFs)

5
1 Scripting/Interaction
GDP per capita

Source of xls file:


http://data.worldbank.org/indicator/NY.GDP.PCAP.CD

7
2 Macros
Monte Carlo Simulation

simulation.py

xlwings_app.py web_app.py

Source Code: https://github.com/ZoomerAnalytics/simulation-demo


Hosted Sample: www.zoomeranalytics.com/simulation-demo

9
3 UDFs
DJIA: Correlation Analysis

Excel’s Correlation formula accepts just 2 data sets:

=CORREL(array1, array2)

Here’s how we’re going to fix this:

• Add CORREL2 to get the full correlation matrix


• Visual representation: Heatmap

11
Summary
(1) Easy Installation

• pip/conda install xlwings


• included in:

13
(2) Cross-Platform

+
(except UDFs)

14
(3) Flexibility

Version Architecture Version Architecture

2.6 32-bit 2003 32-bit


2.7 64-bit 2010 64-bit
3.3 2011 (Mac)
3.4 2013
3.5 2016 (Win + Mac)

15
(4) Simplicity
>>>  from xlwings import Workbook,  Range

>>>  wb =  Workbook()


>>>  Range("A1").value  =  my_variable

• Strings
• Numbers
• DateTime
• Lists (nested)
• NumPy arrays
• Pandas DataFrames
16
(5) Powerful built-in Converters/Options

Range("A1").options(pd.DataFrame).value

@xw.func
@xw.arg("x",  pd.DataFrame)
def myfunction(x):
return x

17
(6) Prototype analytical web apps

vs.

18
Questions?

You might also like