0

Suppose you have a DataFrame like this:

df = pd.DataFrame({"A":[1,2,3], "B": [4,5,6], "C": [7,8,9]})
#    A  B  C
# 0  1  4  7
# 1  2  5  8
# 2  3  6  9 

We have many ways to select a single cell, such as:

df["B"][1]
df["B"].loc[1]
df.loc[1,"B"]
df.loc[1]["B"]

I may not remember all of them, but my question is whether all these ways are equivalent, or which one is better and why?

4

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.