A DataFrame has a column tags whose values are lists of strings. What does df.explode(tags) do?
Correct answer
D. It gives each list element its own row, repeating the other column values
11 views
D. It gives each list element its own row, repeating the other column values
11 views
explode converts a list-like entry into one row per element, duplicating the remaining column values and reusing the original index label. It is the inverse of the groupby-agg-list pattern, not of pivot: to widen a column of lists you need to build the columns yourself. An empty list produces a NaN row rather than disappearing, which is a frequent surprise when counting rows afterwards.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is D? Ask here and get an explanation.