Skip to content
Advertisement

Tag: dataframe

Append new level to DataFrame column

Given a DataFrame, how can I add a new level to the columns based on an iterable given by the user? In other words, how do I append a new level? The question How to simply add a column level to a pandas dataframe shows how to add a new level given a single value, so it doesn’t cover this

Pandas: I want make a new column based on a series

What I want is just to add a column that copy the value of tmp with respect to serial number of c2 and map to c1. Expected result: The length of c1 sequence and c2 sequence are the same. Longer sequence for reproduct: Answer Use Series.map with DataFrame.drop_duplicates, because c2 has duplicates: Details: Solution with merge: EDIT: If need mapping

Advertisement