Pandas

last modified

2023–9–5

Display complete dataframe

with pd.option_context('display.max_rows', None, 'display.max_columns', None):
    display(tt)
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
    print(tt)

Select or remove rows

by index

# select
row = df.loc[index]
# remove
df.drop(indices, inplace=True)
df = df.drop(indices)

by logical expression

# select
df = df[logical]
# remove
df = df[not logical]

logical should be a Series of type bool with index matching df.

Select or remove columns

# select
tt = tt[list_of_column_names]