Skip to content

Commit

Permalink
pep
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Apr 13, 2017
1 parent b2d26eb commit f0e3ad2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion pandas/tests/indexes/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ def test_astype(self):
right=[2, 4],
closed='right')

ci = CategoricalIndex(Categorical.from_codes([0, 1, -1], categories=ii, ordered=True))
ci = CategoricalIndex(Categorical.from_codes(
[0, 1, -1], categories=ii, ordered=True))

result = ci.astype('interval')
expected = ii.take([0, 1, -1])
Expand Down
15 changes: 9 additions & 6 deletions pandas/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,11 +1608,12 @@ def setUp(self):
self.factor = Categorical(['a', 'b', 'b', 'a', 'a', 'c', 'c', 'c'])

df = DataFrame({'value': np.random.randint(0, 10000, 100)})
labels = [ "{0} - {1}".format(i, i + 499) for i in range(0, 10000, 500) ]
labels = ["{0} - {1}".format(i, i + 499) for i in range(0, 10000, 500)]
cat_labels = Categorical(labels, labels)

df = df.sort_values(by=['value'], ascending=True)
df['value_group'] = pd.cut(df.value, range(0, 10500, 500), right=False, labels=cat_labels)
df['value_group'] = pd.cut(df.value, range(0, 10500, 500),
right=False, labels=cat_labels)
self.cat = df

def test_dtypes(self):
Expand Down Expand Up @@ -2019,8 +2020,10 @@ def test_series_functions_no_warnings(self):

def test_assignment_to_dataframe(self):
# assignment
df = DataFrame({'value': np.array(np.random.randint(0, 10000, 100),dtype='int32')})
labels = Categorical(["{0} - {1}".format(i, i + 499) for i in range(0, 10000, 500)])
df = DataFrame({'value': np.array(
np.random.randint(0, 10000, 100), dtype='int32')})
labels = Categorical(["{0} - {1}".format(i, i + 499)
for i in range(0, 10000, 500)])

df = df.sort_values(by=['value'], ascending=True)
s = pd.cut(df.value, range(0, 10500, 500), right=False, labels=labels)
Expand Down Expand Up @@ -3134,7 +3137,7 @@ def test_slicing(self):
df = DataFrame({'value': (np.arange(100) + 1).astype('int64')})
df['D'] = pd.cut(df.value, bins=[0, 25, 50, 75, 100])

expected = Series([11, Interval(0, 25)], index=['value','D'], name=10)
expected = Series([11, Interval(0, 25)], index=['value', 'D'], name=10)
result = df.iloc[10]
tm.assert_series_equal(result, expected)

Expand All @@ -3144,7 +3147,7 @@ def test_slicing(self):
result = df.iloc[10:20]
tm.assert_frame_equal(result, expected)

expected = Series([9, Interval(0, 25)],index=['value', 'D'], name=8)
expected = Series([9, Interval(0, 25)], index=['value', 'D'], name=8)
result = df.loc[8]
tm.assert_series_equal(result, expected)

Expand Down

0 comments on commit f0e3ad2

Please sign in to comment.