#13. Pandas .loc, .iloc in Python - 2 | Tutorial
293 بار بازدید -
4 سال پیش
-
The video discusses slicing, indexing,
The video discusses slicing, indexing, .loc and .iloc for dataframes in Python.
Update: Please check out the 'Important_Note' below.
Timeline & Exercise
(Python 3.7)
00:00 - Welcome
00:09 - Outline of video
00:43 - Open Jupyter Notebook
00:56 - Create data
01:42 - How to pull data from dataframe?
03:15 - .loc() to select rows or columns
04:51 - ——————Correction comment ——————
06:50 - .iloc() to select rows or columns
07:40 - ——————Correction comment ——————
15:05 - End
Exercise:
learndataa exercise for this video can be found at link below:
https://github.com/learndataa/exercises
Important_Note:
------------------------run the code below)------------------------
Example DataFrame
df = pd.DataFrame({'dogs':[3,2,999],'cats':[1,5,1000]}, index=[99,98,0])
.iloc is purely positional by number only
print('df.iloc[0,:]:\n',df.iloc[0,:])
print("Notice!!! that .iloc returns the 1st row in df and NOT row labeled as '0' in index column.")
print('\n')
.loc is by given index or label
print('df.loc[0,:]:\n',df.loc[0,:])
------------------------# -------------------------# ------------------------
Thank you.
Update: Please check out the 'Important_Note' below.
Timeline & Exercise
(Python 3.7)
00:00 - Welcome
00:09 - Outline of video
00:43 - Open Jupyter Notebook
00:56 - Create data
01:42 - How to pull data from dataframe?
03:15 - .loc() to select rows or columns
04:51 - ——————Correction comment ——————
06:50 - .iloc() to select rows or columns
07:40 - ——————Correction comment ——————
15:05 - End
Exercise:
learndataa exercise for this video can be found at link below:
https://github.com/learndataa/exercises
Important_Note:
Example DataFrame
df = pd.DataFrame({'dogs':[3,2,999],'cats':[1,5,1000]}, index=[99,98,0])
.iloc is purely positional by number only
print('df.iloc[0,:]:\n',df.iloc[0,:])
print("Notice!!! that .iloc returns the 1st row in df and NOT row labeled as '0' in index column.")
print('\n')
.loc is by given index or label
print('df.loc[0,:]:\n',df.loc[0,:])
Thank you.
4 سال پیش
در تاریخ 1399/01/28 منتشر شده
است.
293
بـار بازدید شده