-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Where/mask methods for Series #2337
Conversation
1. added __str__ (to do __repr__) 2. row removal in tables is much faster if rows are consecutive 3. added Term class, refactored Selection (this is backdwards compatible) Term is a concise way of specifying conditions for queries, e.g. Term(dict(field = 'index', op = '>', value = '20121114')) Term('index', '20121114') Term('index', '>', '20121114') Term('index', ['20121114','20121114']) Term('index', datetime(2012,11,14)) Term('index>20121114') updated tests for same this should close GH pandas-dev#1996
…e (see test_append) this the result of incompatibility testing on the index_kind
think about doing this automagically for tables
…of index columns minimum size changed pytables version test for indexing around a bit added Col class to manage the column conversions added alias to the Term class; you can specify the nomial indexers (e.g. index in DataFrame, major_axis/minor_axis or alias in Panel) updated docs for pytables to reflect these changes updated docs for indexing to incorporate whatsnew 0.9.1 for where and mask
…d for the cond with a shape like the original
I cherry-picked this. Thanks for the PR! |
added docs for these in commit: 2d57979 |
cherry-picked. Thank you! |
Are the >>> pandas.__version__
'0.9.1'
>>> df['col2'].where
Traceback (most recent call last):
File "<ipython-input-19-885524901cf2>", line 1, in <module>
df['col2'].where
AttributeError: 'Series' object has no attribute 'where' >>> dir(df['col2'])
['T', '_AXIS_ALIASES', '_AXIS_NAMES', '_AXIS_NUMBERS', '__abs__', '__add__', '__and__', '__array__', '__array_finalize__', '__array_interface__', '__array_prepare__', '__array_priority__', '__array_struct__', '__array_wrap__', '__class__', '__contains__', '__copy__', '__deepcopy__', '__delattr__', '__delitem__', '__delslice__', '__dict__', '__div__', '__divmod__', '__doc__', '__eq__', '__float__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__hex__', '__iadd__', '__iand__', '__idiv__', '__ifloordiv__', '__ilshift__', '__imod__', '__imul__', '__index__', '__init__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__long__', '__lshift__', '__lt__', '__mod__', '__module__', '__mul__', '__ne__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__setitem__', '__setslice__', '__setstate__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__weakref__', '__xor__', '_agg_by_level', '_binop', '_can_hold_na', '_check_bool_indexer', '_constructor', '_get_axis', '_get_axis_name', '_get_axis_number', '_get_repr', '_get_val_at', '_get_values', '_get_values_tuple', '_get_with', '_index', '_ix', '_reindex_indexer', '_repr_footer', '_set_labels', '_set_values', '_set_with', '_tidy_repr', 'abs', 'add', 'align', 'all', 'any', 'append', 'apply', 'argmax', 'argmin', 'argsort', 'asfreq', 'asof', 'astype', 'at_time', 'autocorr', 'base', 'between', 'between_time', 'byteswap', 'choose', 'clip', 'clip_lower', 'clip_upper', 'combine', 'combine_first', 'compress', 'conj', 'conjugate', 'copy', 'corr', 'count', 'cov', 'ctypes', 'cummax', 'cummin', 'cumprod', 'cumsum', 'data', 'describe', 'diagonal', 'diff', 'div', 'dot', 'drop', 'dropna', 'dtype', 'dump', 'dumps', 'fill', 'fillna', 'first', 'first_valid_index', 'flags', 'flat', 'flatten', 'from_array', 'from_csv', 'get', 'get_value', 'getfield', 'groupby', 'head', 'hist', 'idxmax', 'idxmin', 'iget', 'iget_value', 'imag', 'index', 'interpolate', 'irow', 'isin', 'isnull', 'item', 'itemset', 'itemsize', 'iteritems', 'iterkv', 'ix', 'keys', 'kurt', 'last', 'last_valid_index', 'load', 'mad', 'map', 'max', 'mean', 'median', 'min', 'mul', 'name', 'nbytes', 'ndim', 'newbyteorder', 'nonzero', 'notnull', 'nunique', 'order', 'pct_change', 'plot', 'prod', 'ptp', 'put', 'quantile', 'rank', 'ravel', 'real', 'reindex', 'reindex_like', 'rename', 'reorder_levels', 'repeat', 'replace', 'resample', 'reset_index', 'reshape', 'resize', 'round', 'save', 'searchsorted', 'select', 'set_value', 'setasflat', 'setfield', 'setflags', 'shape', 'shift', 'size', 'skew', 'sort', 'sort_index', 'sortlevel', 'squeeze', 'std', 'str', 'strides', 'sub', 'sum', 'swapaxes', 'swaplevel', 'tail', 'take', 'to_csv', 'to_dict', 'to_sparse', 'to_string', 'tofile', 'tolist', 'tostring', 'trace', 'transpose', 'truncate', 'tshift', 'tz_convert', 'tz_localize', 'unique', 'unstack', 'update', 'valid', 'value_counts', 'values', 'var', 'view', 'weekday'] |
in 0.9.1 they only exist in a DataFrame docs will explain the slight difference eg s[cond] will return a subset of rows On Nov 28, 2012, at 3:22 PM, Luke Lee notifications@github.com wrote:
|
@jreback Ah, that clears up the confusion. Thanks! |
add where and mask methods for Series, analagous to DataFrame methods added for 0.9.1
passes all tests
where is equivalent to:
s[cond].reindex_like(s).fillna(other)
boolean selection
support setting as well (though not used anywhere explicity)