【发布时间】:2019-11-23 05:42:21
【问题描述】:
试图从列表中选择子集,但是选择后顺序颠倒了
尝试使用 pandas isin
df.mon =[1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12,...]
# selecting
results = df[df.month.isin([10,11,12,1,2,3])]
print(results.mon]
mon = [1,2,3,10,11,12, 1,2,3,10,11,12,...]
desired results
mon= [10,11,12,1,2,3,10,11,12,1,2,3,...]
# sorting results in this
mon = [1,1,2,2,3,3,10,10,11,11,12,12] and I dont want that either
thanks for the help
【问题讨论】:
-
但是,第一个
1, 2, 3在[10, 11, 12, 1, 2, 3]中
标签: python pandas numpy python-xarray