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

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

Post by Anonymous »

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?>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post