Skip to content Skip to sidebar Skip to footer

Pandas Multiple Index Dataframe: Creating New Index Or Appending To Existing Index

I have a Pandas dataframe, multi_df, which has a multi-index made of the code,colour,texture and shape values as below: import pandas as pd import numpy as np df = pd.DataFrame({'i

Solution 1:

append() creates a new series every time, so it's very slow, if you need call this in a for loop:

data = pd.Series(15, index=pd.MultiIndex.from_tuples([('two','white','hard', 'triangular')]))
multi_df.append(data)

Post a Comment for "Pandas Multiple Index Dataframe: Creating New Index Or Appending To Existing Index"