python数据导入spss_有没有一个Python模块打开SPSS文件?

根据您想要做的 – 使用

rpy2中的R相关命令处理数据或切换到Python – 相关线程上的

solution provided by @Spacedman可能会轻松适应您的需要.

>>> 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、付费专栏及课程。

余额充值