spss essentials for python_在SPSS Python essentials中,我可以获得返回到Python以供进一步使用的SPSS变量的值吗?...

将SPSS变量数据转换为Python变量进行操作的最简单方法可能是使用spss.数据集班级。在

为此,您需要:

1.)您的SPSS数据集的数据集名称

2.)要从中提取数据的变量的名称或其在数据集中的索引。在

如果要从中提取数据的变量名命名为“seq”(我相信是在您的问题中),那么您可以使用类似于:BEGIN PROGRAM PYTHON.

from __future__ import with_statement

import spss

with spss.DataStep()

#the lines below create references to your dataset,

#to its variable list, and to its case data

lv_dataset = spss.Dataset(name = )

lv_caseData = lv_dataset.cases

lv_variables = lv_dataset.varlist

#the line below extracts all the data from the SPSS variable named 'seq' in the dataset referenced above into a list

#to make use of an SPSS cases object, you specify in square brackets which rows and which variables to extract from, such as:

#Each row you request to be extracted will be returned as a list of values, one value for each variable you request data for

#lv_theData = lv_caseData[rowStartIndex:rowEndIndex, columnStartIndex:columnEndIndex]

#This means that if you want to get data for one variable across many rows of data, you will get a list for each row of data, but each row's list will have only one value in it, hence in the code below, we grab the first element of each list returned

lv_variableData = [itm[0] for itm in lv_caseData[0:len(lv_caseData), lv_variables['seq'].index]]

END PROGRAM.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值