如何使用Python讀寫SPSS的檔案

使用Pandas

import pandas as pddf = pd.read_spss('fileName.sav')df.tail()######################################################cols = ['ID', 'Day', 'Age', 'Response', 'Gender']
df = pd.read_spss('fileName.sav', usecols=cols)
df.head()

使用Pyreadstat

#讀取
import
pyreadstat

df, meta = pyreadstat.read_sav('fileName.sav')

type(df)
df.head()
#寫入
pyreadstat.write_sav(df, 'fileName.sav')

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store