module binaries.cs_dataframe

Inheritance diagram of csharpyml.binaries.cs_dataframe

Short summary

module csharpyml.binaries.cs_dataframe

Makes C# DataFrame available in Python.

source on GitHub

Classes

class truncated documentation
CSDataFrame Wraps C# DataFrame.

Static Methods

staticmethod truncated documentation
get_cs_class Returns the C# class used to interact with C# DataFrame.
read_csv Creates a dataframe from a csv file.
read_df Converts a DataFrame into a C# DataFrame.
read_str Creates a dataframe from a string.
read_view Converts a C# IDataView into a C# IDataView.

Methods

method truncated documentation
__getattr__ Looks first in the Python class then in the C# class.
__init__ Creates a C# DataFrame.
__str__ usual
to_df Converts the C# DataFrame back into a DataFrame.

Documentation

Makes C# DataFrame available in Python.

source on GitHub

class csharpyml.binaries.cs_dataframe.CSDataFrame(obj=None)[source]

Bases: object

Wraps C# DataFrame.

source on GitHub

Creates a C# DataFrame.

Parameters:objC# DataFrame or None to create an empty one

source on GitHub

__getattr__(name)[source]

Looks first in the Python class then in the C# class.

source on GitHub

__init__(obj=None)[source]

Creates a C# DataFrame.

Parameters:objC# DataFrame or None to create an empty one

source on GitHub

__str__()[source]

usual

source on GitHub

class _wrap_return_(name, fct)[source]

Bases: object

Wraps a C# object into a Python if the returned object is a DataFrame.

source on GitHub

__call__(*args, **kwargs)[source]

Call self as a function.

__init__(name, fct)[source]

Initialize self. See help(type(self)) for accurate signature.

static get_cs_class()[source]

Returns the C# class used to interact with C# DataFrame.

source on GitHub

static read_csv(filename, sep=', ', header=True, names=None, kinds=None, nrows=-1, guess_rows=10, encoding=None, index=False)[source]

Creates a dataframe from a csv file.

Parameters:
  • filename – filename
  • sep – separator
  • header – has header
  • names – columns names (if no header)
  • kinds – types of each columns (see below)
  • nrows – keeps only the first rows
  • guess_rows – number of rows to guess the type is not overriden by kinds
  • encoding – encoding
  • index – add a column with the row index
Returns:

CSDataFrame

kinds can be None to let the function guess the right type, or it can be an array to change the type of every column. -1 indicates the function should guess.

What are kinds?

kind are an enum class which indicates the type of a variable or an array. It is equivalent to an integer. The mapping is defined in file DataKind.

source on GitHub

static read_df(df, columns=None)[source]

Converts a DataFrame into a C# DataFrame.

Parameters:
  • dfDataFrame
  • columns – overwrites the column names
Returns:

CSDataFrame

source on GitHub

static read_str(content, sep=', ', header=True, names=None, kinds=None, nrows=-1, guess_rows=10, index=False)[source]

Creates a dataframe from a string.

Parameters:
  • content – string
  • sep – separator
  • header – has header
  • names – columns names (if no header)
  • kinds – types of each columns (see below)
  • nrows – number of rows to read
  • guess_rows – number of rows to guess the type is not overriden by kinds
  • index – add a column with the row index
Returns:

CSDataFrame

kinds can be None to let the function guess the right type, or it can be an array to change the type of every column. -1 indicates the function should guess.

source on GitHub

static read_view(idataview, nrows=-1)[source]

Converts a C# IDataView into a C# IDataView.

Parameters:
  • idataviewC# IDataView
  • nrows – keeps only the first rows
Returns:

CSDataFrame

source on GitHub

to_df()[source]

Converts the C# DataFrame back into a DataFrame.

Todo

This function does too many copies. It should allocated arrays and ask the C# code to copy the data in it.

source on GitHub