locgets rows (or columns) with particular labels from the index.
# delete columns which ends with column name "Name"
df1 = df.loc[:, ~df.columns.str.endswith('Name')]
# delete columns which contain "Name" in column name
df1 = df.loc[:, ~df.columns.str.contains('Name')]
ilocgets rows (or columns) at particular positions in the index (so it only takes integers).
ixusually tries to behave likelocbut falls back to behaving likeilocif a label is not present in the index.
No comments:
Post a Comment