Skip to content

Commit 3850dd7

Browse files
committed
REF: rename factor.py to categorical.py close #1468
1 parent 1adc68b commit 3850dd7

File tree

11 files changed

+19
-19
lines changed

11 files changed

+19
-19
lines changed

pandas/core/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pandas.core.algorithms import factorize, match, unique, value_counts
77

88
from pandas.core.common import isnull, notnull, save, load
9-
from pandas.core.factor import Categorical, Factor
9+
from pandas.core.categorical import Categorical, Factor
1010
from pandas.core.format import (set_printoptions, reset_printoptions,
1111
set_eng_float_format)
1212
from pandas.core.index import Index, Int64Index, MultiIndex
File renamed without changes.

pandas/core/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44

55
from pandas.core.algorithms import unique
6-
from pandas.core.factor import Factor
6+
from pandas.core.categorical import Factor
77
from pandas.core.frame import DataFrame
88
from pandas.core.generic import NDFrame
99
from pandas.core.index import Index, MultiIndex, _ensure_index

pandas/core/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ def from_arrays(cls, arrays, sortorder=None, names=None):
14581458
-------
14591459
index : MultiIndex
14601460
"""
1461-
from pandas.core.factor import Factor
1461+
from pandas.core.categorical import Factor
14621462

14631463
if len(arrays) == 1:
14641464
name = None if names is None else names[0]

pandas/core/panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from pandas.core.common import (PandasError, _mut_exclusive,
1111
_try_sort, _default_index, _infer_dtype)
12-
from pandas.core.factor import Factor
12+
from pandas.core.categorical import Factor
1313
from pandas.core.index import (Index, MultiIndex, _ensure_index,
1414
_get_combined_index)
1515
from pandas.core.indexing import _NDFrameIndexer, _maybe_droplevels

pandas/io/pytables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from pandas.core.common import adjoin
1919
from pandas.core.algorithms import match, unique
2020

21-
from pandas.core.factor import Factor
21+
from pandas.core.categorical import Factor
2222
from pandas.core.common import _asarray_tuplesafe
2323
from pandas.core.internals import BlockManager, make_block
2424
from pandas.core.reshape import block2d_to_block3d

pandas/tests/test_factor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import numpy as np
88

99
from pandas.core.api import value_counts
10-
from pandas.core.factor import Categorical
10+
from pandas.core.categorical import Categorical
1111
from pandas.core.index import Index, Int64Index, MultiIndex
1212
from pandas.util.testing import assert_almost_equal
1313
import pandas.core.common as com

pandas/tests/test_groupby.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pandas import bdate_range
88
from pandas.core.index import Index, MultiIndex
99
from pandas.core.common import rands
10-
from pandas.core.api import Factor, DataFrame
10+
from pandas.core.api import Categorical, DataFrame
1111
from pandas.core.groupby import GroupByError
1212
from pandas.core.series import Series
1313
from pandas.util.testing import (assert_panel_equal, assert_frame_equal,
@@ -1900,27 +1900,27 @@ def test_no_dummy_key_names(self):
19001900
self.df['B'].values]).sum()
19011901
self.assert_(result.index.names == [None, None])
19021902

1903-
def test_groupby_factor(self):
1903+
def test_groupby_categorical(self):
19041904
levels = ['foo', 'bar', 'baz', 'qux']
19051905
labels = np.random.randint(0, 4, size=100)
19061906

1907-
factor = Factor(labels, levels, name='myfactor')
1907+
cats = Categorical(labels, levels, name='myfactor')
19081908

19091909
data = DataFrame(np.random.randn(100, 4))
19101910

1911-
result = data.groupby(factor).mean()
1911+
result = data.groupby(cats).mean()
19121912

1913-
expected = data.groupby(np.asarray(factor)).mean()
1913+
expected = data.groupby(np.asarray(cats)).mean()
19141914
expected = expected.reindex(levels)
19151915

19161916
assert_frame_equal(result, expected)
1917-
self.assert_(result.index.name == factor.name)
1917+
self.assert_(result.index.name == cats.name)
19181918

1919-
grouped = data.groupby(factor)
1919+
grouped = data.groupby(cats)
19201920
desc_result = grouped.describe()
19211921

1922-
idx = factor.labels.argsort()
1923-
ord_labels = np.asarray(factor).take(idx)
1922+
idx = cats.labels.argsort()
1923+
ord_labels = np.asarray(cats).take(idx)
19241924
ord_data = data.take(idx)
19251925
expected = ord_data.groupby(ord_labels, sort=False).describe()
19261926
assert_frame_equal(desc_result, expected)

pandas/tests/test_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010
from numpy.testing import assert_array_equal
1111

12-
from pandas.core.factor import Factor
12+
from pandas.core.categorical import Factor
1313
from pandas.core.index import Index, Int64Index, MultiIndex
1414
from pandas.util.testing import assert_almost_equal
1515
from pandas.util import py3compat

pandas/tools/merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import numpy as np
66

7-
from pandas.core.factor import Factor
7+
from pandas.core.categorical import Factor
88
from pandas.core.frame import DataFrame, _merge_doc
99
from pandas.core.generic import NDFrame
1010
from pandas.core.groupby import get_group_index

pandas/tools/tile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from pandas.core.api import DataFrame, Series
6-
from pandas.core.factor import Factor
6+
from pandas.core.categorical import Categorical
77
import pandas.core.algorithms as algos
88
import pandas.core.common as com
99
import pandas.core.nanops as nanops
@@ -181,7 +181,7 @@ def _bins_to_cuts(x, bins, right=True, labels=None, retbins=False,
181181
if has_nas:
182182
np.putmask(ids, mask, 0)
183183

184-
fac = Factor(ids - 1, levels, name=name)
184+
fac = Categorical(ids - 1, levels, name=name)
185185
else:
186186
fac = ids - 1
187187
if has_nas:

0 commit comments

Comments
 (0)