Skip to content

Commit 3aaa37e

Browse files
Addressing review comments
1 parent fcb1297 commit 3aaa37e

File tree

9 files changed

+14
-26
lines changed

9 files changed

+14
-26
lines changed

pandas/core/common.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,6 @@ def try_sort(iterable):
214214
return listed
215215

216216

217-
def dict_keys_to_ordered_list(mapping):
218-
return list(mapping.keys())
219-
220-
221217
def asarray_tuplesafe(values, dtype=None):
222218

223219
if not (isinstance(values, (list, tuple)) or hasattr(values, "__array__")):

pandas/core/frame.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,16 +3500,12 @@ def assign(self, **kwargs):
35003500
Notes
35013501
-----
35023502
Assigning multiple columns within the same ``assign`` is possible.
3503-
For Python 3.6 and above, later items in '\*\*kwargs' may refer to
3504-
newly created or modified columns in 'df'; items are computed and
3505-
assigned into 'df' in order. For Python 3.5 and below, the order of
3506-
keyword arguments is not specified, you cannot refer to newly created
3507-
or modified columns. All items are computed first, and then assigned
3508-
in alphabetical order.
3503+
Later items in '\*\*kwargs' may refer to newly created or modified
3504+
columns in 'df'; items are computed and assigned into 'df' in order.
35093505
35103506
.. versionchanged:: 0.23.0
35113507
3512-
Keyword argument order is maintained for Python 3.6 and later.
3508+
Keyword argument order is maintained.
35133509
35143510
Examples
35153511
--------
@@ -3535,9 +3531,8 @@ def assign(self, **kwargs):
35353531
Portland 17.0 62.6
35363532
Berkeley 25.0 77.0
35373533
3538-
In Python 3.6+, you can create multiple columns within the same assign
3539-
where one of the columns depends on another one defined within the same
3540-
assign:
3534+
You can create multiple columns within the same assign where one
3535+
of the columns depends on another one defined within the same assign:
35413536
35423537
>>> df.assign(temp_f=lambda x: x['temp_c'] * 9 / 5 + 32,
35433538
... temp_k=lambda x: (x['temp_f'] + 459.67) * 5 / 9)

pandas/core/generic.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import re
99
from textwrap import dedent
1010
from typing import (
11-
TYPE_CHECKING,
1211
Any,
1312
Callable,
1413
Dict,
@@ -190,9 +189,7 @@ class NDFrame(PandasObject, SelectionMixin):
190189
_metadata = [] # type: List[str]
191190
_is_copy = None
192191
_data = None # type: BlockManager
193-
194-
if TYPE_CHECKING:
195-
_attrs = {} # type: Dict[Hashable, Any]
192+
_attrs = {} # type: Dict[Optional[Hashable], Any]
196193

197194
# ----------------------------------------------------------------------
198195
# Constructors

pandas/core/internals/construction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def init_dict(data, index, columns, dtype=None):
233233
arrays.loc[missing] = [val] * missing.sum()
234234

235235
else:
236-
keys = com.dict_keys_to_ordered_list(data)
236+
keys = list(data.keys())
237237
columns = data_names = Index(keys)
238238
arrays = (com.maybe_iterable_to_list(data[k]) for k in keys)
239239
# GH#24096 need copy to be deep for datetime64tz case
@@ -526,7 +526,7 @@ def _list_of_dict_to_arrays(data, columns, coerce_float=False, dtype=None):
526526
"""Convert list of dicts to numpy arrays
527527
528528
if `columns` is not passed, column names are inferred from the records
529-
- for OrderedDict and (on Python>=3.6) dicts, the column names match
529+
- for OrderedDict and dicts, the column names match
530530
the key insertion-order from the first record to the last.
531531
- For other kinds of dict-likes, the keys are lexically sorted.
532532

pandas/core/reshape/concat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def __init__(
293293

294294
if isinstance(objs, dict):
295295
if keys is None:
296-
keys = com.dict_keys_to_ordered_list(objs)
296+
keys = list(objs.keys())
297297
objs = [objs[k] for k in keys]
298298
else:
299299
objs = list(objs)

pandas/tests/frame/test_constructors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ def test_constructor_list_of_dict_order(self):
13601360
}
13611361
)
13621362
result = DataFrame(data)
1363-
tm.assert_frame_equal(result, expected, check_like=False)
1363+
tm.assert_frame_equal(result, expected)
13641364

13651365
def test_constructor_orient(self, float_string_frame):
13661366
data_dict = float_string_frame.T._series

pandas/tests/indexing/test_indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def test_setitem_dtype_upcast(self):
221221
expected = DataFrame(
222222
[{"a": 1, "b": np.nan, "c": "foo"}, {"a": 3, "b": 2, "c": np.nan}]
223223
)
224-
tm.assert_frame_equal(df, expected, check_like=False)
224+
tm.assert_frame_equal(df, expected)
225225

226226
# GH10280
227227
df = DataFrame(

pandas/tests/io/json/test_normalize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def test_missing_field(self, author_missing_data):
380380
},
381381
]
382382
expected = DataFrame(ex_data)
383-
tm.assert_frame_equal(result, expected, check_like=False)
383+
tm.assert_frame_equal(result, expected)
384384

385385
@pytest.mark.parametrize(
386386
"max_level,expected",
@@ -522,7 +522,7 @@ def test_missing_meta(self, missing_metadata):
522522
columns = ["city", "number", "state", "street", "zip", "name"]
523523
columns = ["number", "street", "city", "state", "zip", "name"]
524524
expected = DataFrame(ex_data, columns=columns)
525-
tm.assert_frame_equal(result, expected, check_like=False)
525+
tm.assert_frame_equal(result, expected)
526526

527527
def test_donot_drop_nonevalues(self):
528528
# GH21356

pandas/tests/reshape/test_concat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ def test_concat_dict(self):
12641264
"qux": DataFrame(np.random.randn(4, 3)),
12651265
}
12661266

1267-
sorted_keys = com.dict_keys_to_ordered_list(frames)
1267+
sorted_keys = list(frames.keys())
12681268

12691269
result = concat(frames)
12701270
expected = concat([frames[k] for k in sorted_keys], keys=sorted_keys)

0 commit comments

Comments
 (0)