loc
gets 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')]
iloc
gets rows (or columns) at particular positions in the index (so it only takes integers).
ix
usually tries to behave likeloc
but falls back to behaving likeiloc
if a label is not present in the index.
No comments:
Post a Comment