python spss,有没有一个Python模块打开SPSS文件?

Is there a module for Python to open IBM SPSS (i.e. .sav) files? It would be great if there's something up-to-date which doesn't require any additional dll files/libraries.

解决方案

Depending on what you want to do--process data using R-related commands from rpy2, or switch to Python--the solution provided by @Spacedman on a related thread might easily be adapted to suit your needs.

Otherwise, Pandas includes a convenient wrapper for rpy2. Here is an example of use with Peat and Barton's weights.sav data set:

>>> import pandas.rpy.common as com

>>> filename = "weights.sav"

>>> w = com.robj.r('foreign::read.spss("%s", to.data.frame=TRUE)' % filename)

>>> w = com.convert_robj(w)

>>> w.head()

ID WEIGHT LENGTH HEADC GENDER EDUCATIO PARITY

1 L001 3.95 55.5 37.5 Female tertiary 3 or more siblings

2 L003 4.63 57.0 38.5 Female tertiary Singleton

3 L004 4.75 56.0 38.5 Male year12 2 siblings

4 L005 3.92 56.0 39.0 Male tertiary One sibling

5 L006 4.56 55.0 39.5 Male year10 2 siblings

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值