PyCallUtils.jl

Extensions to PyCall.jl
Author AStupidBear
Popularity
9 Stars
Updated Last
10 Months Ago
Started In
October 2019

Extensions to PyCall.jl

Build Status Coverage

Installation

using Pkg
pkg"add PyCallUtils"

Usage

using PyCall, PyCallUtils

Import modules and functions from python elegantly

@imports numpy as np
@from datetime imports datetime

Transfer SparseMatrixCSC to/from scipy

using SparseArrays
x = sprand(100, 100, 0.5)
@assert convert(SparseMatrixCSC, PyObject(x)) == x

Serialize/Deserialize python object to BSON.jl

using BSON
BSON.@save "test.bson" x = np.sin

Make getindex/setindex! behave exactly like in python

@imports pandas as pd
df = pd.DataFrame(Dict(:name => ["a", "b"], :age => [27, 30]))
@assert df.loc[1, "age"] == 30
sr = pd.Series([3, 5], index = [:a, :b])
@assert all(sr.iloc[0:1] == sr)
@assert all(sr.iloc[:] == sr)