Pandas > Filter rows or columns

Name
Code
Output
dataframe = pandas.DataFrame(numpy.random.randint(0,10,size=(5, 3)), columns=['C1','C2','C3'])
print ("dataframe")
print (dataframe)
dataframe2 = dataframe.filter(items=[1,3],axis=0)
print ("dataframe selected items")
print (dataframe2)
dataframe3 = dataframe.filter(items=['C1','C3'],axis=1)
print ("dataframe selected items")
print (dataframe3)
dataframe
   C1  C2  C3
0   8   2   8
1   5   7   7
2   9   5   0
3   6   8   1
4   0   1   9
dataframe selected items
   C1  C2  C3
1   5   7   7
3   6   8   1
dataframe selected items
   C1  C3
0   8   8
1   5   7
2   9   0
3   6   1
4   0   9