[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Converting Python objects (especially pandas dataframes) to Julia objects. Extends the functionality of PyCall.jl for specific packages.

License

Notifications You must be signed in to change notification settings

JuliaTagBot/PyConversions.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyConversions.jl

This package provides methods for converting from Python objects to Julia objects, as well as a minimal Julia interface to pickle. PyCall.jl already provides an enormous amount of functionality for converting from Python objects to Julia objects, but it is somewhat lacking when it comes to specific python modules, notably pandas. Much of PyConversions.jl is for converting to or from pandas dataframes.

API Docs

# PyConversions.convertPyColumnMethod.

convertPyColumn(pycol::PyObject)

Converts a column of a pandas array to a Julia NullableArray.

# PyConversions.convertPyDFMethod.

convertPyDF(pydf[, fixtypes=true])

Converts a pandas dataframe to a Julia one.

Note that it is difficult to infer the correct types of columns which contain references to Python objects. If fixtypes, this will attempt to convert any column with eltype Any to the proper type.

# PyConversions.fixColumnTypes!Method.

fixColumnTypes!(df)

Check to see if the dataframe df has any columns of type Any and attempt to convert them to the proper types. This can be called from convertPyDF with the option fixtypes.

# PyConversions.fixPyNones!Method.

fixPyNones!(df::DataTable)

Attempts to automatically convert all columns of a dataframe to have eltype Any while replacing all Python Nones with Nullable().

# PyConversions.fixPyNones!Method.

fixPyNones!(dtype::DataType, df::DataTable, col::Symbol)

Attempts to convert a column of the dataframe to have eltype dtype while replacing all Python Nones with Nullable().

# PyConversions.fixPyNonesMethod.

fixPyNones(dtype, a)

Attempts to convert a NullableArray to have eltype dtype while replacing all Python Nones with Nullable.

# PyConversions.pandasMethod.

pandas(df)

Convert a dataframe to a pandas pyobject.

# PyConversions.pickleMethod.

pickle(filename, object)

Converts the provided object to a PyObject and serializes it in the python pickle format. If the object provided is a DataTable, this will first convert it to a pandas dataframe.

# PyConversions.unpickleMethod.

unpickle([dtype,] filename[, fixtypes=true])

Deserializes a python pickle file and returns the object it contains. Additionally, if DataTable is given as the first argument, will attempt to convert the object to a Julia dataframe with the flag fixtypes (see convertPyDF).

About

Converting Python objects (especially pandas dataframes) to Julia objects. Extends the functionality of PyCall.jl for specific packages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages