How to Select a item in a cell in a Pandas Dataframe? - Python Recipes

preview_player
Показать описание
This video provide a quick tutorial on how to directly access or set an item in a Pandas Dataframe in Python.

SUBSCRIBE TO OUR YOUTUBE CHANNEL

#python #recipes #dataanalytics #datascience #pandas #dataframe

How do i select an item in a cell in a pandas data frame?

In this video we will learn how to select an item in a cell in a pandas data frame before.
Watch the video and follow along with the python commented code below:

# import pandas library
import pandas as pd

# Create a dataframe from a dictionary
# first create dictionary with data
data_dict = {'country': ['Brazil','Argentina','Canada'],
'capital':['Brasilia','Buenos Aires', 'Ottawa'],
'language':['Portuguese', 'Spanish', 'English']}

# use disctionary to create the dataframe
df= pd.DataFrame(data_dict)
df

# Select dataframe cells using the iat method

# Select dataframe cells using the at method

# These methods can also be used for set operations
df

df
Рекомендации по теме
Комментарии
Автор

Bravo!!!! I was using the iloc[0, 1] to select a cell. Is the iat[0, 1] a better way of doing it?

oscarsibanda
welcome to shbcf.ru