diff --git a/pandas/core/frame.py b/pandas/core/frame.py index ab7d23acf183e..ee986f1a466b1 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -333,6 +333,41 @@ def f(self, other): class DataFrame(NDFrame): + """ Two-dimensional size-mutable, potentially heterogeneous tabular data + structure with labeled axes (rows and columns). Arithmetic operations + align on both row and column labels. Can be thought of as a dict-like + container for Series objects. The primary pandas data structure + + Parameters + ---------- + data : numpy ndarray (structured or homogeneous), dict, or DataFrame + Dict can contain Series, arrays, constants, or list-like objects + index : Index or array-like + Index to use for resulting frame. Will default to np.arange(n) if + no indexing information part of input data and no index provided + columns : Index or array-like + Will default to np.arange(n) if not column labels provided + dtype : dtype, default None + Data type to force, otherwise infer + copy : boolean, default False + Copy data from inputs. Only affects DataFrame / 2d ndarray input + + Examples + -------- + >>> d = {'col1': ts1, 'col2': ts2} + >>> df = DataFrame(data=d, index=index) + >>> df2 = DataFrame(np.random.randn(10, 5)) + >>> df3 = DataFrame(np.random.randn(10, 5), + ... columns=['a', 'b', 'c', 'd', 'e']) + + See also + -------- + DataFrame.from_records: constructor from tuples, also record arrays + DataFrame.from_dict: from dicts of Series, arrays, or dicts + DataFrame.from_csv: from CSV files + DataFrame.from_items: from sequence of (key, value) pairs + read_csv / read_table / read_clipboard + """ _auto_consolidate = True _het_axis = 1 _info_axis = 'columns' @@ -347,41 +382,6 @@ class DataFrame(NDFrame): def __init__(self, data=None, index=None, columns=None, dtype=None, copy=False): - """Two-dimensional size-mutable, potentially heterogeneous tabular data - structure with labeled axes (rows and columns). Arithmetic operations - align on both row and column labels. Can be thought of as a dict-like - container for Series objects. The primary pandas data structure - - Parameters - ---------- - data : numpy ndarray (structured or homogeneous), dict, or DataFrame - Dict can contain Series, arrays, constants, or list-like objects - index : Index or array-like - Index to use for resulting frame. Will default to np.arange(n) if - no indexing information part of input data and no index provided - columns : Index or array-like - Will default to np.arange(n) if not column labels provided - dtype : dtype, default None - Data type to force, otherwise infer - copy : boolean, default False - Copy data from inputs. Only affects DataFrame / 2d ndarray input - - Examples - -------- - >>> d = {'col1': ts1, 'col2': ts2} - >>> df = DataFrame(data=d, index=index) - >>> df2 = DataFrame(np.random.randn(10, 5)) - >>> df3 = DataFrame(np.random.randn(10, 5), - ... columns=['a', 'b', 'c', 'd', 'e']) - - See also - -------- - DataFrame.from_records: constructor from tuples, also record arrays - DataFrame.from_dict: from dicts of Series, arrays, or dicts - DataFrame.from_csv: from CSV files - DataFrame.from_items: from sequence of (key, value) pairs - read_csv / read_table / read_clipboard - """ if data is None: data = {} diff --git a/pandas/core/index.py b/pandas/core/index.py index 43cb7734a1cc5..a6da188c6011c 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -1,7 +1,5 @@ # pylint: disable=E1101,E1103,W0232 -from datetime import time - from itertools import izip import numpy as np diff --git a/pandas/core/panel.py b/pandas/core/panel.py index 8e18e93e955ef..4f346d2e1860e 100644 --- a/pandas/core/panel.py +++ b/pandas/core/panel.py @@ -147,6 +147,24 @@ def f(self, other): class Panel(NDFrame): + """ + Represents wide format panel data, stored as 3-dimensional array + + Parameters + ---------- + data : ndarray (items x major x minor), or dict of DataFrames + items : Index or array-like + axis=1 + major_axis : Index or array-like + axis=1 + minor_axis : Index or array-like + axis=2 + dtype : dtype, default None + Data type to force, otherwise infer + copy : boolean, default False + Copy data from inputs. Only affects DataFrame / 2d ndarray input + """ + _AXIS_ORDERS = ['items', 'major_axis', 'minor_axis'] _AXIS_NUMBERS = dict([(a, i) for i, a in enumerate(_AXIS_ORDERS)]) _AXIS_ALIASES = { @@ -218,23 +236,6 @@ def _construct_axes_dict_for_slice(self, axes=None, **kwargs): def __init__(self, data=None, items=None, major_axis=None, minor_axis=None, copy=False, dtype=None): - """ - Represents wide format panel data, stored as 3-dimensional array - - Parameters - ---------- - data : ndarray (items x major x minor), or dict of DataFrames - items : Index or array-like - axis=1 - major_axis : Index or array-like - axis=1 - minor_axis : Index or array-like - axis=2 - dtype : dtype, default None - Data type to force, otherwise infer - copy : boolean, default False - Copy data from inputs. Only affects DataFrame / 2d ndarray input - """ self._init_data( data=data, items=items, major_axis=major_axis, minor_axis=minor_axis, copy=copy, dtype=dtype) diff --git a/pandas/core/series.py b/pandas/core/series.py index 919dd57ee70ab..4115c3e6abc3a 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -386,6 +386,33 @@ def f(self, axis=0, dtype=None, out=None, skipna=True, level=None): class Series(pa.Array, generic.PandasObject): + """ + One-dimensional ndarray with axis labels (including time series). + Labels need not be unique but must be any hashable type. The object + supports both integer- and label-based indexing and provides a host of + methods for performing operations involving the index. Statistical + methods from ndarray have been overridden to automatically exclude + missing data (currently represented as NaN) + + Operations between Series (+, -, /, *, **) align values based on their + associated index values-- they need not be the same length. The result + index will be the sorted union of the two indexes. + + Parameters + ---------- + data : array-like, dict, or scalar value + Contains data stored in Series + index : array-like or Index (1d) + Values must be unique and hashable, same length as data. Index + object (or other iterable of same length as data) Will default to + np.arange(len(data)) if not provided. If both a dict and index + sequence are used, the index will override the keys found in the + dict. + dtype : numpy.dtype or None + If None, dtype will be inferred copy : boolean, default False Copy + input data + copy : boolean, default False + """ _AXIS_NUMBERS = { 'index': 0 } @@ -411,7 +438,7 @@ def __new__(cls, data=None, index=None, dtype=None, name=None, elif isinstance(data, dict): if index is None: from pandas.util.compat import OrderedDict - if isinstance(data,OrderedDict): + if isinstance(data, OrderedDict): index = Index(data) else: index = Index(sorted(data)) @@ -482,33 +509,6 @@ def from_array(cls, arr, index=None, name=None, copy=False): def __init__(self, data=None, index=None, dtype=None, name=None, copy=False): - """ - One-dimensional ndarray with axis labels (including time series). - Labels need not be unique but must be any hashable type. The object - supports both integer- and label-based indexing and provides a host of - methods for performing operations involving the index. Statistical - methods from ndarray have been overridden to automatically exclude - missing data (currently represented as NaN) - - Operations between Series (+, -, /, *, **) align values based on their - associated index values-- they need not be the same length. The result - index will be the sorted union of the two indexes. - - Parameters - ---------- - data : array-like, dict, or scalar value - Contains data stored in Series - index : array-like or Index (1d) - Values must be unique and hashable, same length as data. Index - object (or other iterable of same length as data) Will default to - np.arange(len(data)) if not provided. If both a dict and index - sequence are used, the index will override the keys found in the - dict. - dtype : numpy.dtype or None - If None, dtype will be inferred copy : boolean, default False Copy - input data - copy : boolean, default False - """ pass @property diff --git a/pandas/sparse/series.py b/pandas/sparse/series.py index b799188170e6f..6ad165570038e 100644 --- a/pandas/sparse/series.py +++ b/pandas/sparse/series.py @@ -74,6 +74,23 @@ def _sparse_series_op(left, right, op, name): class SparseSeries(SparseArray, Series): + """Data structure for labeled, sparse floating point data + + Parameters + ---------- + data : {array-like, Series, SparseSeries, dict} + kind : {'block', 'integer'} + fill_value : float + Defaults to NaN (code for missing) + sparse_index : {BlockIndex, IntIndex}, optional + Only if you have one. Mainly used internally + + Notes + ----- + SparseSeries objects are immutable via the typical Python means. If you + must change values, convert to dense, make your changes, then convert back + to sparse + """ __array_priority__ = 15 sp_index = None @@ -168,23 +185,6 @@ def from_array(cls, arr, index=None, name=None, copy=False, fill_value=None): def __init__(self, data, index=None, sparse_index=None, kind='block', fill_value=None, name=None, copy=False): - """Data structure for labeled, sparse floating point data - -Parameters ----------- -data : {array-like, Series, SparseSeries, dict} -kind : {'block', 'integer'} -fill_value : float - Defaults to NaN (code for missing) -sparse_index : {BlockIndex, IntIndex}, optional - Only if you have one. Mainly used internally - -Notes ------ -SparseSeries objects are immutable via the typical Python means. If you -must change values, convert to dense, make your changes, then convert back -to sparse - """ pass @property diff --git a/pandas/tseries/period.py b/pandas/tseries/period.py index 51903b7179822..14119dd94290a 100644 --- a/pandas/tseries/period.py +++ b/pandas/tseries/period.py @@ -40,29 +40,28 @@ def f(self): class Period(object): + """ + Represents an period of time + Parameters + ---------- + value : Period or basestring, default None + The time period represented (e.g., '4Q2005') + freq : str, default None + e.g., 'B' for businessday, ('T', 5) or '5T' for 5 minutes + year : int, default None + month : int, default 1 + quarter : int, default None + day : int, default 1 + hour : int, default 0 + minute : int, default 0 + second : int, default 0 + """ __slots__ = ['freq', 'ordinal'] def __init__(self, value=None, freq=None, ordinal=None, year=None, month=1, quarter=None, day=1, hour=0, minute=0, second=0): - """ - Represents an period of time - - Parameters - ---------- - value : Period or basestring, default None - The time period represented (e.g., '4Q2005') - freq : str, default None - e.g., 'B' for businessday, ('T', 5) or '5T' for 5 minutes - year : int, default None - month : int, default 1 - quarter : int, default None - day : int, default 1 - hour : int, default 0 - minute : int, default 0 - second : int, default 0 - """ # freq points to a tuple (base, mult); base is one of the defined # periods such as A, Q, etc. Every five minutes would be, e.g., # ('T', 5) but may be passed in as a string like '5T'