[Tutor] reading variables in a data set?
Luke Paireepinart
rabidpoobear at gmail.com
Sun Jul 5 02:30:08 CEST 2009
Pardon me, I don't have time to address all of your questions; however,
Steven Buck wrote:
> I gather it's now a list where each element of the list is an
> observation (a vector) for one household. The name of my list is
> "data"; I gather Python recognizes the first observation by: data[1] .
No, the first item in a list is going to be data[0], not data[1].
Python counts from 0 not 1. Unless by the "first observation" you mean
the "one after the zeroth observation" but that is not the common usage
of that term.
> Example,
> data = [X_1, X_2, X_3, . . . . , X_N] where each X_i for all i, is
> vector of household characteristics, eg X_1 = (age_1, wage_1, . . . ,
> residence_1).
>
> I also have a list for variable names called "varname"; although I'm
> not sure the module I used to extract the ".dta" into Python also
> created a correspondence between the varname list and the data
> list--the python interpreter won't print anything when I type one of
> the variable names, I was hoping it would print out a vector of ages
> or the like.
It should output whatever is contained in the variable, if you're at the
interpreter. Sounds like you're not getting your data in.
>>> x = ["hello", "world!", 42]
>>> x
['hello', 'world!', 42]
Hope that helps a litttle bit, good luck!
-Luke
More information about the Tutor
mailing list