- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
How to retrieve the data of Series using labels or Index | pandas | Pandas Data Structure Series
In Pandas Series, you can retrieve the data using labels or index using the loc and iloc methods. Here's how to use them:
loc: loc is used to retrieve data using the labels of the index. You can pass a single label, a list of labels, or a slice of labels to the loc method to retrieve the corresponding data from the Series. For example:
import pandas as pd
s = pd.Series([10, 20, 30, 40], index=['a', 'b', 'c', 'd'])
print(s.loc['a']) # Output: 10
print(s.loc[['a', 'c']]) # Output: a 10\n c 30\ndtype: int64
print(s.loc['b': 'd']) # Output: b 20\nc 30\nd 40\ndtype: int64
iloc: iloc is used to retrieve data using the integer position of the index. You can pass a single integer, a list of integers, or a slice of integers to the iloc method to retrieve the corresponding data from the Series. For example:
import pandas as pd
s = pd.Series([10, 20, 30, 40], index=['a', 'b', 'c', 'd'])
print(s.iloc[0]) # Output: 10
print(s.iloc[[0, 2]]) # Output: a 10\nc 30\ndtype: int64
print(s.iloc[1:3]) # Output: b 20\nc 30\ndtype: int64
Note that the difference between loc and iloc is that loc uses the label of the index to retrieve data, while iloc uses the integer position of the index to retrieve data.
Code snippet is given below
# retrieving the data single label(index)
s = pd.Series([1,2,3,4,5], index=['a','b','c','d','e'])
print(s)
# retrieve a single element
print(s['a'])
# retriving non existing element
print(s['f'])
# retrive a multiple elements
print(s[['a','c','d']])
@ParagDhawan
=============================================================================
Link for Tutorial Series
Jupyter Notebook Tutorial Series:-
https://www.youtube.com/watch?v=kguFtorzvxk&list=PLWkNktG0P7z8xPPlc1zv7_DobZzFIsWKi
Python Tutorial Series:-
https://www.youtube.com/watch?v=FL9vhKVhzT4&list=PLWkNktG0P7z-0g6vY1XqeEq2_JuQYRv1P
Python Assignments and Objective Questions:-
https://www.youtube.com/watch?v=qqhxJmzlDBQ&list=PLWkNktG0P7z9sRRitFMAdkKMutekF7k1M
Tech. Videos By Parag Dhawan;-
https://www.youtube.com/watch?v=osLpuHDAvn8&list=PLWkNktG0P7z-xGz3B5fG5P9t_4GC133ax
Object-Oriented Programming in Python:-
https://www.youtube.com/watch?v=z_8jY2CoIJY&list=PLWkNktG0P7z8NLuyLIeWUn7B1IEcNNq_T
File Handling in Python:-
https://www.youtube.com/watch?v=SjcD6f2nQRM&list=PLWkNktG0P7z_k1LkcLHJc3sE34pT8-Efu
Exception Handling in Python:-
https://www.youtube.com/playlist?list=PLWkNktG0P7z9LegCxgt80mn4jMOsAGlH5
NumPy Tutorial Series:-
https://www.youtube.com/playlist?list=PLWkNktG0P7z9A_6uxRlj6NoaLO5QGeWPA
=============================================================================
Feel free to connect and ask your queries:-
Linkedin:- https://www.linkedin.com/in/parag-dhawan
Youtube:- https://www.youtube.com/c/ParagDhawan
Facebook Page:- http://fb.me/dhawanparag
Instagram: - https://www.instagram.com/paragdhawan/
Twitter:- https://twitter.com/dhawan_parag
GitHub:- https://github.com/paragdhawan/
=============================================================================
Show your support by Subscribing to the channel:-
https://www.youtube.com/c/ParagDhawan?sub_confirmation=1
=============================================================================
#ParagDhawan
#Pandas
#DataScience
#DataAnalysis
#PandasTutorial
#PandasCourse
#Python3
#Python
#PythonProgramming
============================================================
How to Record Your Screen and make a tutorial video or demo video: -
https://www.youtube.com/watch?v=3zmtwAr96_k&t=0s
============================================================
Видео How to retrieve the data of Series using labels or Index | pandas | Pandas Data Structure Series канала Parag Dhawan
loc: loc is used to retrieve data using the labels of the index. You can pass a single label, a list of labels, or a slice of labels to the loc method to retrieve the corresponding data from the Series. For example:
import pandas as pd
s = pd.Series([10, 20, 30, 40], index=['a', 'b', 'c', 'd'])
print(s.loc['a']) # Output: 10
print(s.loc[['a', 'c']]) # Output: a 10\n c 30\ndtype: int64
print(s.loc['b': 'd']) # Output: b 20\nc 30\nd 40\ndtype: int64
iloc: iloc is used to retrieve data using the integer position of the index. You can pass a single integer, a list of integers, or a slice of integers to the iloc method to retrieve the corresponding data from the Series. For example:
import pandas as pd
s = pd.Series([10, 20, 30, 40], index=['a', 'b', 'c', 'd'])
print(s.iloc[0]) # Output: 10
print(s.iloc[[0, 2]]) # Output: a 10\nc 30\ndtype: int64
print(s.iloc[1:3]) # Output: b 20\nc 30\ndtype: int64
Note that the difference between loc and iloc is that loc uses the label of the index to retrieve data, while iloc uses the integer position of the index to retrieve data.
Code snippet is given below
# retrieving the data single label(index)
s = pd.Series([1,2,3,4,5], index=['a','b','c','d','e'])
print(s)
# retrieve a single element
print(s['a'])
# retriving non existing element
print(s['f'])
# retrive a multiple elements
print(s[['a','c','d']])
@ParagDhawan
=============================================================================
Link for Tutorial Series
Jupyter Notebook Tutorial Series:-
https://www.youtube.com/watch?v=kguFtorzvxk&list=PLWkNktG0P7z8xPPlc1zv7_DobZzFIsWKi
Python Tutorial Series:-
https://www.youtube.com/watch?v=FL9vhKVhzT4&list=PLWkNktG0P7z-0g6vY1XqeEq2_JuQYRv1P
Python Assignments and Objective Questions:-
https://www.youtube.com/watch?v=qqhxJmzlDBQ&list=PLWkNktG0P7z9sRRitFMAdkKMutekF7k1M
Tech. Videos By Parag Dhawan;-
https://www.youtube.com/watch?v=osLpuHDAvn8&list=PLWkNktG0P7z-xGz3B5fG5P9t_4GC133ax
Object-Oriented Programming in Python:-
https://www.youtube.com/watch?v=z_8jY2CoIJY&list=PLWkNktG0P7z8NLuyLIeWUn7B1IEcNNq_T
File Handling in Python:-
https://www.youtube.com/watch?v=SjcD6f2nQRM&list=PLWkNktG0P7z_k1LkcLHJc3sE34pT8-Efu
Exception Handling in Python:-
https://www.youtube.com/playlist?list=PLWkNktG0P7z9LegCxgt80mn4jMOsAGlH5
NumPy Tutorial Series:-
https://www.youtube.com/playlist?list=PLWkNktG0P7z9A_6uxRlj6NoaLO5QGeWPA
=============================================================================
Feel free to connect and ask your queries:-
Linkedin:- https://www.linkedin.com/in/parag-dhawan
Youtube:- https://www.youtube.com/c/ParagDhawan
Facebook Page:- http://fb.me/dhawanparag
Instagram: - https://www.instagram.com/paragdhawan/
Twitter:- https://twitter.com/dhawan_parag
GitHub:- https://github.com/paragdhawan/
=============================================================================
Show your support by Subscribing to the channel:-
https://www.youtube.com/c/ParagDhawan?sub_confirmation=1
=============================================================================
#ParagDhawan
#Pandas
#DataScience
#DataAnalysis
#PandasTutorial
#PandasCourse
#Python3
#Python
#PythonProgramming
============================================================
How to Record Your Screen and make a tutorial video or demo video: -
https://www.youtube.com/watch?v=3zmtwAr96_k&t=0s
============================================================
Видео How to retrieve the data of Series using labels or Index | pandas | Pandas Data Structure Series канала Parag Dhawan
How to retrieve the data of Series using labels or Index labels pandas pandas data structure series pandas tutorial accesing element of series retriving data from pandas series python data science parag dhawan Iloc Loc Indexing Data engineering Data preprocessing Data management Data visualization Exploratory data analysis Data wrangling Data structures Beginner-friendly Programming tutorials Python programming DataFrames Data manipulation Data analysis Pandas
Комментарии отсутствуют
Информация о видео
23 октября 2021 г. 8:05:05
00:02:55
Другие видео канала




















