Wie kann ich Etiketten bewahren, wenn die SPSS -Datei (.sav) über RPY in Pandas importiert wird?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie kann ich Etiketten bewahren, wenn die SPSS -Datei (.sav) über RPY in Pandas importiert wird?

by Anonymous » 10 Apr 2025, 05:48

Ich möchte mit Pandas an einer SPSS -Dateien (.sav) arbeiten. In the absence of the SPSS program, here's what a typical file looks like when converted to .csv:

Image


On investigation into what the first two rows signify (I don't know SPSS), es scheint, dass die erste Zeile das Etikett s enthält, während die zweite Zeile den Varname s. Pandas also: < /p>

Code: Select all

import pandas.rpy.common as com

def savtocsv(filename):
w = com.robj.r('foreign::read.spss("%s", to.data.frame=TRUE)' % filename)
w = com.convert_robj(w)
return w
and then do a head(), the first row (Label) is missing:

Image


How can labels be beibehalten?>

Top