- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在索引列中我有一个日期列表:
DatetimeIndex(['2010-12-31', '2011-01-02', '2011-01-03', '2011-01-29',
'2011-02-26', '2011-02-28', '2011-03-26', '2011-03-31',
'2011-04-01', '2011-04-03',
...
'2016-02-27', '2016-02-29', '2016-03-26', '2016-03-31',
'2016-04-01', '2016-04-03', '2016-04-30', '2016-05-31',
'2016-06-30', '2016-07-02'],
dtype='datetime64[ns]', length=123, freq=None)
但是我想过滤掉所有月和日等于 12/31、3/31、6/30、9/30 的值,以获得季度末的值。
有解决这个问题的好方法吗?
最佳答案
您可以使用 is_quarter_end
过滤行标签:
In [151]:
df = pd.DataFrame(np.random.randn(400,1), index= pd.date_range(start=dt.datetime(2016,1,1), periods=400))
df.loc[df.index.is_quarter_end]
Out[151]:
0
2016-03-31 -0.474125
2016-06-30 0.931780
2016-09-30 -0.281271
2016-12-31 0.325521
关于python - Pandas 按季度结束日期过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39598618/
我有以下数据框: Data <- data.frame( date = c("2001-01-01", "2001-02-01", "2001-03-01", "2001-04-01", "200
我在基于 [Date] 字段的选择查询中使用这些公式。学期为 1 月至 6 月 1 个学期,7 月至 12 月为 2 个学期。季度是 3 个月的版本(1 月至 3 月等为 1)。 case when
我有一些用户上传的数据,需要根据用户选择的时间段进行存储和排序。期间应该只支持月年或季度年,没有其他,类似于下面: +----+---------+-------+ | id | pe
我有一个 pandas DataFrame,其中有一列(标题)需要被解析为日期时间对象,以便我可以将其转换为时间序列。 Title Gross Domestic Product: Quar
oracle按天,周,月,季度,年查询排序 ? 1
我有 32 年的数据要放入分区表中。但是 BigQuery 说我超过了限制(4000 个分区)。 对于像这样的查询: CREATE TABLE `deleting.day_partition` PAR
我们将从以下数据表开始: id date 1: 1 2016-03-31 2: 1 2015-12-31 3: 1 2015-09-30 4: 1 2015-06-
我知道与计划相关的里程碑的年份和季度(例如“2010”和“4”),并且我想从中选择/创建一个日期时间。有许多巧妙的方法可以用特定日期的格式(“qq”)来识别季度,但不能反过来(或者有吗?)。这是使用
我需要获得给定日期的相应三个月(3 个月的时间段,即 1 月、2 月和 3 月的第一个三个月)。使用 c# System.DateTime 结构我没有设法找到我正在寻找的方法。所以我这样解决了: Da
我的数据集包含 48 周内每一天的信息。[我的数据集截图][1] 我希望创建一个名为“quarter”的新变量,将每一个week变量值=1-12的观测值标记为“a”,意思是“第一季度”;另外,将每个周
我正在寻找一个 java 库,当给出起始日期和截止日期时,它将返回最适用的日期列表(以周、月、季度或年为单位)。我已经手动完成了这项工作,我想知道这是否已经作为标准包的一部分实现和测试。 例子 给定
我想做两件事: 我想将 x 轴格式设置为四分之一。我的时间序列数据以季度为单位。例如,对于日期 2012-12-31 我希望它显示为 2012Q4,对于 2013-03-31 作为 2013Q1 ,对
我是一名优秀的程序员,十分优秀!