【发布时间】:2020-12-28 23:44:36
【问题描述】:
我有一个大熊猫系列,所以优化是关键
pd.Series(['I like apples', 'They went skiing vacation', 'Apples are tasty', 'The skiing was great'], dtype='string')
0 I like apples
1 They went skiing vacation
2 Apples are tasty
3 The skiing was great
dtype: string
考虑行是字符串列表,即第 0 行是 ['I', 'like', 'apples']。
我想获取“apples”的索引并根据该索引的值对行重新排序。在这个例子中,系列看起来像:
2 Apples are tasty
0 I like apples
1 They went skiing vacation
3 The skiing was great
dtype: string
因为“apples”的索引(忽略区分大小写)在第 2 行中为 0。
【问题讨论】: