1# A B C
2# 0 1 3 5
3# 1 2 4 6
4
5column_B = a_dataframe.iloc[:, 1]
6print(column_B)
7
8# OUTPUT
9# 0 3
10# 1 4
1from pandas import DataFrame
2
3boxes = {'Color': ['Green','Green','Green','Blue','Blue','Red','Red','Red'],
4 'Shape': ['Rectangle','Rectangle','Square','Rectangle','Square','Square','Square','Rectangle'],
5 'Price': [10,15,5,5,10,15,15,5]
6 }
7
8df = DataFrame(boxes, columns= ['Color','Shape','Price'])
9
10select_color = df.loc[df['Color'] == 'Green']
11print (select_color)
12
1df1 = df.iloc[:,0:2] # Remember that Python does not slice inclusive of the ending index.
1iloc - default indexes (system generated)
2loc - table indexes or we manually given indexes
1df = df.loc[df.index.repeat(df['a'])]
2df['c'] = df.groupby(level=0).cumcount() + 1
3df = df.reset_index(drop=True)
4print (df)
5 a b c
60 1 x 1
71 2 y 1
82 2 y 2
93 3 z 1
104 3 z 2
115 3 z 3
12