I'm a python newbie but have some R experience. In R if I'd like to subset a data.frame I can use a variable to do something like this:
# Columns
# Assign column names to variable
colsToUse <- c('col1','col2','col3')
# Use variable to subset
df2 <- df1[,colsToUse]
# Rows
# Assign column names to variable
rowsToUse <- sample(1:nrows(df1), 500)
# Use variable to subset
df3 <- df1[rowsToUse,]
How would I do this in python?