Skip to content

Commit a4a18a9

Browse files
jbrockmendeljreback
authored andcommitted
Assorted cleanups (#26975)
1 parent cfd65e9 commit a4a18a9

File tree

5 files changed

+15
-28
lines changed

5 files changed

+15
-28
lines changed

Diff for: pandas/core/internals/managers.py

-19
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from pandas.core.dtypes.missing import isna
2424

2525
import pandas.core.algorithms as algos
26-
from pandas.core.arrays.sparse import _maybe_to_sparse
2726
from pandas.core.base import PandasObject
2827
from pandas.core.index import Index, MultiIndex, ensure_index
2928
from pandas.core.indexing import maybe_convert_indices
@@ -1727,10 +1726,6 @@ def form_blocks(arrays, names, axes):
17271726
object_blocks = _simple_blockify(items_dict['ObjectBlock'], np.object_)
17281727
blocks.extend(object_blocks)
17291728

1730-
if len(items_dict['SparseBlock']) > 0:
1731-
sparse_blocks = _sparse_blockify(items_dict['SparseBlock'])
1732-
blocks.extend(sparse_blocks)
1733-
17341729
if len(items_dict['CategoricalBlock']) > 0:
17351730
cat_blocks = [make_block(array, klass=CategoricalBlock, placement=[i])
17361731
for i, _, array in items_dict['CategoricalBlock']]
@@ -1797,20 +1792,6 @@ def _multi_blockify(tuples, dtype=None):
17971792
return new_blocks
17981793

17991794

1800-
def _sparse_blockify(tuples, dtype=None):
1801-
""" return an array of blocks that potentially have different dtypes (and
1802-
are sparse)
1803-
"""
1804-
1805-
new_blocks = []
1806-
for i, names, array in tuples:
1807-
array = _maybe_to_sparse(array)
1808-
block = make_block(array, placement=[i])
1809-
new_blocks.append(block)
1810-
1811-
return new_blocks
1812-
1813-
18141795
def _stack_arrays(tuples, dtype):
18151796

18161797
# fml

Diff for: pandas/io/formats/format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ def __call__(self, num):
15671567

15681568
formatted = format_str.format(mant=mant, prefix=prefix)
15691569

1570-
return formatted # .strip()
1570+
return formatted
15711571

15721572

15731573
def set_eng_float_format(accuracy=3, use_eng_prefix=False):

Diff for: pandas/io/sql.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def insert_data(self):
623623
# GH 9086: Ensure we return datetimes with timezone info
624624
# Need to return 2-D data; DatetimeIndex is 1D
625625
d = b.values.to_pydatetime()
626-
d = np.expand_dims(d, axis=0)
626+
d = np.atleast_2d(d)
627627
else:
628628
# convert to microsecond resolution for datetime.datetime
629629
d = b.values.astype('M8[us]').astype(object)

Diff for: pandas/tests/frame/test_constructors.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import numpy as np
77
import numpy.ma as ma
8+
import numpy.ma.mrecords as mrecords
89
import pytest
910

1011
from pandas.compat import PY36, is_platform_little_endian
@@ -839,7 +840,7 @@ def test_constructor_maskedrecarray_dtype(self):
839840
data = np.ma.array(
840841
np.ma.zeros(5, dtype=[('date', '<f8'), ('price', '<f8')]),
841842
mask=[False] * 5)
842-
data = data.view(ma.mrecords.mrecarray)
843+
data = data.view(mrecords.mrecarray)
843844
result = pd.DataFrame(data, dtype=int)
844845
expected = pd.DataFrame(np.zeros((5, 2), dtype=int),
845846
columns=['date', 'price'])
@@ -868,7 +869,7 @@ def test_constructor_mrecarray(self):
868869
# call assert_frame_equal for all selections of 3 arrays
869870
for comb in itertools.combinations(arrays, 3):
870871
names, data = zip(*comb)
871-
mrecs = ma.mrecords.fromarrays(data, names=names)
872+
mrecs = mrecords.fromarrays(data, names=names)
872873

873874
# fill the comb
874875
comb = {k: (v.filled() if hasattr(v, 'filled') else v)

Diff for: pandas/tests/frame/test_missing.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,15 @@ def test_fillna_mixed_float(self, mixed_float_frame):
241241
result = mf.fillna(method='pad')
242242
_check_mixed_float(result, dtype=dict(C=None))
243243

244-
def test_fillna_other(self):
244+
def test_fillna_empty(self):
245245
# empty frame (GH #2778)
246246
df = DataFrame(columns=['x'])
247247
for m in ['pad', 'backfill']:
248248
df.x.fillna(method=m, inplace=True)
249249
df.x.fillna(method=m)
250250

251-
# with different dtype (GH3386)
251+
def test_fillna_different_dtype(self):
252+
# with different dtype (GH#3386)
252253
df = DataFrame([['a', 'a', np.nan, 'a'], [
253254
'b', 'b', np.nan, 'b'], ['c', 'c', np.nan, 'c']])
254255

@@ -261,6 +262,7 @@ def test_fillna_other(self):
261262
df.fillna({2: 'foo'}, inplace=True)
262263
assert_frame_equal(df, expected)
263264

265+
def test_fillna_limit_and_value(self):
264266
# limit and value
265267
df = DataFrame(np.random.randn(10, 3))
266268
df.iloc[2:7, 0] = np.nan
@@ -272,8 +274,9 @@ def test_fillna_other(self):
272274
result = df.fillna(999, limit=1)
273275
assert_frame_equal(result, expected)
274276

277+
def test_fillna_datelike(self):
275278
# with datelike
276-
# GH 6344
279+
# GH#6344
277280
df = DataFrame({
278281
'Date': [pd.NaT, Timestamp("2014-1-1")],
279282
'Date2': [Timestamp("2013-1-1"), pd.NaT]
@@ -285,8 +288,9 @@ def test_fillna_other(self):
285288
result = df.fillna(value={'Date': df['Date2']})
286289
assert_frame_equal(result, expected)
287290

291+
def test_fillna_tzaware(self):
288292
# with timezone
289-
# GH 15855
293+
# GH#15855
290294
df = pd.DataFrame({'A': [pd.Timestamp('2012-11-11 00:00:00+01:00'),
291295
pd.NaT]})
292296
exp = pd.DataFrame({'A': [pd.Timestamp('2012-11-11 00:00:00+01:00'),
@@ -299,8 +303,9 @@ def test_fillna_other(self):
299303
pd.Timestamp('2012-11-11 00:00:00+01:00')]})
300304
assert_frame_equal(df.fillna(method='bfill'), exp)
301305

306+
def test_fillna_tzaware_different_column(self):
302307
# with timezone in another column
303-
# GH 15522
308+
# GH#15522
304309
df = pd.DataFrame({'A': pd.date_range('20130101', periods=4,
305310
tz='US/Eastern'),
306311
'B': [1, 2, np.nan, np.nan]})

0 commit comments

Comments
 (0)