Skip to content

Commit 6a4d675

Browse files
committed
REF: Factor -> Categorical.
1 parent 4ab3a1f commit 6a4d675

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

pandas/core/frame.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,8 +1659,8 @@ def convert_objects(self, convert_dates=True, convert_numeric=False, copy=True):
16591659
-------
16601660
converted : DataFrame
16611661
"""
1662-
return self._constructor(self._data.convert(convert_dates=convert_dates,
1663-
convert_numeric=convert_numeric,
1662+
return self._constructor(self._data.convert(convert_dates=convert_dates,
1663+
convert_numeric=convert_numeric,
16641664
copy=copy))
16651665

16661666
#----------------------------------------------------------------------
@@ -3330,7 +3330,7 @@ def fillna(self, value=None, method=None, axis=0, inplace=False,
33303330
a reference to the filled object, which is self if inplace=True
33313331
limit : int, default None
33323332
Maximum size gap to forward or backward fill
3333-
downcast : dict, default is None, a dict of item->dtype of what to
3333+
downcast : dict, default is None, a dict of item->dtype of what to
33343334
downcast if possible
33353335
33363336
See also
@@ -3380,7 +3380,7 @@ def fillna(self, value=None, method=None, axis=0, inplace=False,
33803380
result[k].fillna(v, inplace=True)
33813381
return result
33823382
else:
3383-
new_data = self._data.fillna(value, inplace=inplace,
3383+
new_data = self._data.fillna(value, inplace=inplace,
33843384
downcast=downcast)
33853385

33863386
if inplace:
@@ -3791,8 +3791,8 @@ def combine(self, other, func, fill_value=None, overwrite=True):
37913791
result[col] = arr
37923792

37933793
# convert_objects just in case
3794-
return self._constructor(result,
3795-
index=new_index,
3794+
return self._constructor(result,
3795+
index=new_index,
37963796
columns=new_columns).convert_objects(
37973797
convert_dates=True,
37983798
copy=False)
@@ -3825,7 +3825,7 @@ def combiner(x, y, needs_i8_conversion=False):
38253825
y_values = y_values.view('i8')
38263826
else:
38273827
mask = isnull(x_values)
3828-
3828+
38293829
return expressions.where(mask, y_values, x_values, raise_on_error=True)
38303830

38313831
return self.combine(other, combiner, overwrite=False)
@@ -5406,11 +5406,11 @@ def group_agg(values, bounds, f):
54065406

54075407
def factor_agg(factor, vec, func):
54085408
"""
5409-
Aggregate array based on Factor
5409+
Aggregate array based on Categorical
54105410
54115411
Parameters
54125412
----------
5413-
factor : Factor
5413+
factor : Categorical
54145414
length n
54155415
vec : sequence
54165416
length n
@@ -5419,7 +5419,11 @@ def factor_agg(factor, vec, func):
54195419
54205420
Returns
54215421
-------
5422-
ndarray corresponding to Factor levels
5422+
ndarray corresponding to factor levels
5423+
5424+
See Also
5425+
--------
5426+
pandas.Categorical
54235427
"""
54245428
indexer = np.argsort(factor.labels)
54255429
unique_labels = np.arange(len(factor.levels))

pandas/core/panel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
_try_sort, _default_index,
1111
_infer_dtype_from_scalar,
1212
notnull)
13-
from pandas.core.categorical import Factor
13+
from pandas.core.categorical import Categorical
1414
from pandas.core.index import (Index, MultiIndex, _ensure_index,
1515
_get_combined_index)
1616
from pandas.core.indexing import _maybe_droplevels, _is_list_like
@@ -82,8 +82,8 @@ def panel_index(time, panels, names=['time', 'panel']):
8282
(1962, 'C')], dtype=object)
8383
"""
8484
time, panels = _ensure_like_indices(time, panels)
85-
time_factor = Factor.from_array(time)
86-
panel_factor = Factor.from_array(panels)
85+
time_factor = Categorical.from_array(time)
86+
panel_factor = Categorical.from_array(panels)
8787

8888
labels = [time_factor.labels, panel_factor.labels]
8989
levels = [time_factor.levels, panel_factor.levels]

pandas/core/reshape.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,9 @@ def make_axis_dummies(frame, axis='minor', transform=None):
749749
axis : {'major', 'minor'}, default 'minor'
750750
transform : function, default None
751751
Function to apply to axis labels first. For example, to
752-
get "day of week" dummies in a time series regression
752+
get "day of week" dummies in a time series regression
753753
you might call::
754-
754+
755755
make_axis_dummies(panel, axis='major',
756756
transform=lambda d: d.weekday())
757757
Returns
@@ -810,6 +810,6 @@ def block2d_to_blocknd(values, items, shape, labels, ref_items=None):
810810

811811

812812
def factor_indexer(shape, labels):
813-
""" given a tuple of shape and a list of Factor lables, return the expanded label indexer """
813+
""" given a tuple of shape and a list of Categorical labels, return the expanded label indexer """
814814
mult = np.array(shape)[::-1].cumprod()[::-1]
815815
return com._ensure_platform_int(np.sum(np.array(labels).T * np.append(mult, [1]), axis=1).T)

pandas/tools/merge.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import itertools
66
import numpy as np
77

8-
from pandas.core.categorical import Factor
8+
from pandas.core.categorical import Categorical
99
from pandas.core.frame import DataFrame, _merge_doc
1010
from pandas.core.generic import NDFrame
1111
from pandas.core.groupby import get_group_index
@@ -1190,7 +1190,7 @@ def _make_concat_multiindex(indexes, keys, levels=None, names=None):
11901190
names = [None] * len(zipped)
11911191

11921192
if levels is None:
1193-
levels = [Factor.from_array(zp).levels for zp in zipped]
1193+
levels = [Categorical.from_array(zp).levels for zp in zipped]
11941194
else:
11951195
levels = [_ensure_index(x) for x in levels]
11961196
else:
@@ -1228,7 +1228,7 @@ def _make_concat_multiindex(indexes, keys, levels=None, names=None):
12281228
levels.extend(concat_index.levels)
12291229
label_list.extend(concat_index.labels)
12301230
else:
1231-
factor = Factor.from_array(concat_index)
1231+
factor = Categorical.from_array(concat_index)
12321232
levels.append(factor.levels)
12331233
label_list.append(factor.labels)
12341234

0 commit comments

Comments
 (0)