Created
April 14, 2016 18:10
-
-
Save michaelgugino/554db0656cd1b5a21da22da58bf5af99 to your computer and use it in GitHub Desktop.
How to build anything with cython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#mylib.pyx | |
import pandas as pd | |
df = pd.DataFrame({ 'A' : 1., | |
'B' : pd.Timestamp('20130102'), | |
'C' : pd.Series(1, index=list(range(4)), dtype='float32'), | |
'D' : pd.Series([1, 2, 1, 2], dtype='int32'), | |
'E' : pd.Categorical(["test", "train", "test", "train"]), | |
'F' : 'foo' }) | |
#setup.py | |
from distutils.core import setup | |
from Cython.Build import cythonize | |
setup( | |
ext_modules = cythonize("mylib.pyx") | |
) | |
#run on cli: | |
python setup.py build_ext --inplace | |
#usemylib.py | |
import mylib | |
print mylib.df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment