Open jekwatt opened 3 years ago
Add a single row of data:
d1 = {k1: v1}
df.append(d1, ignore_index=True) # conflicting index
Add rows:
# conflicting index, fields not in the same order
# future version of Pandas will set the sort to False by default
df.append(df2, ignore_index=True, sort=False)
# unlike drop method, don't have inplace method to use
df = df.append(df2, ignore_index=True, sort=False)
Remove a row:
df.drop(index=4)
Remove rows using conditional:
mask = (df["col_1"] == v1)
df.drop(index=df[mask].index)
These will go under notebooks/03_modifying.
Add columns:
Remove columns:
df.drop(columns=["col_1", "col_2"], inplace=True)