【发布时间】:2017-04-10 12:19:02
【问题描述】:
Dec 47
Nov 36
Oct 14
Sep 2
Jan 2
Aug 2
May 1
Apr 1
Jun 1
Jul 1
Feb 1
Name: date, dtype: int64
我正在尝试按月对索引列为月的上述系列进行排序。然而,排序函数不是按月份的日历顺序排序,而是按月份名称的字典顺序排序。如何正确排序上述内容?猜猜我必须指定索引类型是月份而不是字符串。任何帮助表示赞赏。代码如下:sn-p。
import calendar
movies = release_dates[release_dates.title.str.contains('Christmas') & (release_dates.country=='USA')]
movies = movies.date.dt.month.apply(lambda x: calendar.month_abbr[x])
counts = movies.value_counts()
counts
【问题讨论】: