Horje
pandas select column by index Code Example
pandas select column by index
#    A  B  C
# 0  1  3  5
# 1  2  4  6

column_B = a_dataframe.iloc[:, 1]
print(column_B)

# OUTPUT
# 0    3
# 1    4
Source: www.kite.com
select rows from dataframe pandas
from pandas import DataFrame

boxes = {'Color': ['Green','Green','Green','Blue','Blue','Red','Red','Red'],
         'Shape': ['Rectangle','Rectangle','Square','Rectangle','Square','Square','Square','Rectangle'],
         'Price': [10,15,5,5,10,15,15,5]
        }

df = DataFrame(boxes, columns= ['Color','Shape','Price'])

select_color = df.loc[df['Color'] == 'Green']
print (select_color)
select columns pandas
df1 = df.iloc[:,0:2] # Remember that Python does not slice inclusive of the ending index.
retrieve row by index pandas
rowData = dfObj.loc[ 'b' , : ]




Python

Related
remove  python Code Example remove  python Code Example
mean of a column pandas Code Example mean of a column pandas Code Example
python get all file names in a dir Code Example python get all file names in a dir Code Example
get all file names in a folder python Code Example get all file names in a folder python Code Example
open a filename starting with in python Code Example open a filename starting with in python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7