In a pandas dataframe created like this:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randint(10, size=(6, 6)),
colu
Adding onto @evan058's answer:
subset(df[rownames(df) %in% c("r3", "r4", "r5"),], select=c1:c4)
c1 c2 c3 c4
r3 3 4 5 6
r4 4 5 6 7
r5 5 6 7 8
But note, the : operator will probably not work here; you will have to write out the name of each row you want to include explicitly. It might be easier to group by a particular value of one of your other columns or to create an index column as @evan058 mentioned in comments.