Applying formats to compued vars

未关闭
#175 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
api, data

调研方向

首先,使用 CASTable、computedvars、columnInfo() 以及经过筛选的 head() 调用运行所提供的 Python 复现代码。跟踪将格式应用于计算出的时间列后对后续表操作的影响,并在保留该格式且按 price 筛选 tbl 仍能成功执行时,将此问题视为已完成。

由索引模型根据 Issue 内容生成。

描述

Hi,

it would be very helpful if formats could be applied to computed variables - especially when working with date/time columns. The functionality seems to be there, but it's breaking the table reference.

Example: Based on a datetime column I can successfully add a time column that holds the hour of the datetime column.

# example table
conn.datastep.runCode(
	code =
	'''data test;
		format datetime e8601dt19.;
		datetime = dhms("03mar2024"d, 9, 50, 0);
		price    = 101.4;
		output;
		datetime = dhms("03mar2024"d, 10, 20, 0);
		price    = 102.5;
		output;
	run;''',
	single = 'yes'
)
tbl = conn.CASTable('test')

# add column containing the hour of the datetime column
tbl['time'] = tbl['datetime'].dt.hour*60*60

# apply time format to new column
tbl.computedvars = [{'name':'time', 'format':'time8.'}]

# check if time format was applied
tbl.columnInfo()

image

# check if time format works
tbl.head()

image

Unfortunately, after applying the format as shown above, I can't execute any operations on the table anymore:

tbl[tbl['price']>=102].head()

image

主要语言
Python
星标
159
派生
65
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sassoftware/python-swat 的其他 Issue

查看 sassoftware/python-swat 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。