我在 5 行的组(数据框)中有 20 列。我想强制仅对 2 列进行排序并保持其他列不变。
我试过使用
group2['Col1','Col2'] = group2['Col1','Col2'].sort_values(by=['Col2'])
它产生错误
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: ('col1', 'col2')
输入和期望的输出是:
哔哔one
相关分类