/    Sign up×
Bounties /Pin to ProfileBookmark

What’s the difference between df[x] and df[‘x’] in Pandas?

to post a answer

1 Replies

Copy linkTweet thisAlerts:
@sayzlimAug 12.2022 — We're talking about Python variables here. The "df" is usually a named variable that we refers to Pandas DataFrame. You can also call it something else.

We often use df['x'] to refer the header name of your tabular data. For example, if you have a DataFrame with the following headers:

Title, Description, Price

You can refer to your DataFrame's "Title" with df["Title"]

df[x] refers to the x variable.

For example:

x = "Title"

df[x] is equal to df["Title"]


Help @AustinDavis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 3.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ

legal: ({
terms: of use,
privacy: policy
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
recent_tips: (
tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 10 SATS,