Using .AT() and .IAT()

.AT() and .IAT()

February 25, 2021 · 4 mins read
#using .AT() and .IAT
import pandas as pd
stats = pd.read_csv('D:\\OneDrive - office365hubs.com\\.Python for data science\\Demographic-Data.csv')
stats.columns = ['CountryName','CountryCode','BirthRate','InternetUsers','IncomeGroup']
stats.head()
CountryName CountryCode BirthRate InternetUsers IncomeGroup
0 Aruba ABW 10.244 78.9 High income
1 Afghanistan AFG 35.253 5.9 Low income
2 Angola AGO 45.985 19.1 Upper middle income
3 Albania ALB 12.877 57.2 Upper middle income
4 United Arab Emirates ARE 11.044 88.0 High income
###Accessing individual elements
#.at() for labels
#.iat() for integer location
stats.iat[3,4]
'Upper middle income'
stats.iat[0,1]
'ABW'
stats.at[2,'BirthRate']
45.985
sub10 = stats[::10]
sub10
CountryName CountryCode BirthRate InternetUsers IncomeGroup
0 Aruba ABW 10.244 78.900000 High income
10 Azerbaijan AZE 18.300 58.700000 Upper middle income
20 Belarus BLR 12.500 54.170000 Upper middle income
30 Canada CAN 10.900 85.800000 High income
40 Costa Rica CRI 15.022 45.960000 Upper middle income
50 Ecuador ECU 21.070 40.353684 Upper middle income
60 Gabon GAB 30.555 9.200000 Upper middle income
70 Greenland GRL 14.500 65.800000 High income
80 India IND 20.291 15.100000 Lower middle income
90 Kazakhstan KAZ 22.730 54.000000 Upper middle income
100 Libya LBY 21.425 16.500000 Upper middle income
110 Moldova MDA 12.141 45.000000 Lower middle income
120 Mozambique MOZ 39.705 5.400000 Low income
130 Netherlands NLD 10.200 93.956400 High income
140 Poland POL 9.600 62.849200 High income
150 Sudan SDN 33.477 22.700000 Lower middle income
160 Suriname SUR 18.455 37.400000 Upper middle income
170 Tajikistan TJK 30.792 16.000000 Lower middle income
180 Uruguay URY 14.374 57.690000 High income
190 Yemen, Rep. YEM 32.947 20.000000 Lower middle income
sub10.iat[10,0]
'Libya'
sub10.at[10,'CountryName']
'Azerbaijan'