Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: DataFrame move doc from __init__ to cls #3342

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 = {}

Expand Down
2 changes: 0 additions & 2 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# pylint: disable=E1101,E1103,W0232

from datetime import time

from itertools import izip

import numpy as np
Expand Down
35 changes: 18 additions & 17 deletions pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down
56 changes: 28 additions & 28 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions pandas/sparse/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
33 changes: 16 additions & 17 deletions pandas/tseries/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down