Release 0.1.1 Andrew Straw, Florian Finkernagel

pydataframe Documentation

Release 0.1.1 Andrew Straw, Florian Finkernagel

February 21, 2014

1 Core classes 2 Functions 3 Reading and writing 4 Dialects 5 Indices and tables Python Module Index

Contents

1 5 7 9 11 13

i

ii

CHAPTER 1

Core classes

class DataFrame(value_dict=None, columns_ordered=None, row_names_ordered=None) An implemention of an almost R like DataFrame object. Usage: u = DataFrame( { "Field1": [1, 2, 3], "Field2": ['abc', 'def', 'hgi']}, optional: ['Field1', 'Field2'] ["rowOne", "rowTwo", "thirdRow"])

A DataFrame is basically a table with rows and columns. Columns are named, rows are numbered (but can be named) and can be easily selected and calculated upon. Internally, columns are stored as 1d numpy arrays. If you set row names, they're converted into a dictionary for fast access. There is a rich subselection/slicing API, see help(DataFrame.__get_item) (it also works for setting values). Please note that any slice get's you another DataFrame, to access individual entries use get_row(), get_column(), get_value(). DataFrames also understand basic arithmetic and you can either add (multiply,...) a constant value, or another DataFrame of the same size / with the same column names. aggregate(key_vars, aggregation_function)

Iterate for every value combination of the key vars, call the aggregation_function with the sub-df. Take the returned dicts, turn them into a new df as2DMatrix(dtype=None) Return all columns as 2d(nRows, nCols)-numpy matrix. Please use pep 8 conform as_2d_matrix() Default dtype is float64 Raises a ValueError if not all columns could be converted. as_2d_matrix(dtype=None) Return all columns as 2d(nRows, nCols)-numpy matrix. Default dtype is float64 Raises a ValueError if not all columns could be converted. cbind_view(*others) Stack frames next to each other ( column wise ). Take frames with distinct fields, but identical row lengths, and stack them next to each other in order. The new DataFrame shares the values with its parents. convert_type(column_name, value_casting_func) Cast a column into another type copy() Return a deep copy of the DataFrame.

1

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download