![]() ![]() # Both variables are recorded as integers with two implicit decimal places, so the value 2575 means that the respondent's age was 25.75. # For each pregnancy in the NSFG dataset, the variable 'agecon' encodes the respondent's age at conception, and 'agepreg' the respondent's age at the end of the pregnancy. # Confirm that the value 8 no longer appears in this column by printing the values and their frequencies. # In the 'nbrnaliv' column, replace the value 8, in place, with the special value NaN. Recall from the video how Allen replaced the values 98 and 99 in the ounces column using the. # Your job in this exercise is to replace this value with np.nan. value_counts() to view the responses, you'll see that the value 8 appears once, and if you consult the codebook, you'll see that this value indicates that the respondent refused to answer the question. # In the NSFG dataset, the variable 'nbrnaliv' records the number of babies born alive at the end of a pregnancy. nan) # np.nan means we are getting the special value NaN from the NumPy library ![]() # replace takes a list of values we want to replace and the value we want to replace them with By default results are sorted with most freq value first so using sort_index() sorts them by value instead ![]() # value_counts() to see what values appear in pounds and how many times each value appears. Let's begin exploring the NSFG data! It has been pre-loaded for you into a DataFrame called nsfg. The result is an Index, which is a Pandas data structure that is similar to a list. # To get the column names, you can read the columns attribute. # To get the number of rows and columns in a DataFrame, you can read its shape attribute. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |