Skip to content

Bug BBQ: Call to reset_index in merging lesson not needed? #224

Open
@colinmorris

Description

@colinmorris

The merging lesson has the following code excerpt:

# read in first 10 lines of surveys table
survey_sub = surveys_df.head(10)
# grab the last 10 rows 
survey_sub_last10 = surveys_df.tail(10)
#reset the index values to the second dataframe appends properly
survey_sub_last10=survey_sub_last10.reset_index(drop=True)
# drop=True option avoids adding new index column with old index values

It's not really explained why reset_index needs to be called for the second frame to append "properly". I tried following along without resetting the index, and it seemed to do the right thing. Of course there's a big gap between the index values in the first and second half of the concatenated df, but that seems fine to me (and even preferable to having duplicate index values, which happens if you call reset_index).

I'm inclined to remove that line, but it's possible I'm missing something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedLooking for Contributorstype:clarificationSuggest change for make lesson clearer

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions