TransWikia.com

Not able to find a particular value in a column in pandas but I can find it in R

Stack Overflow Asked by user11675397 on November 27, 2021

Df

 A
123
234
374
493

Python

Df[Df['A']==234]

I get no value.

R

Df[Df$A %in% c('234')]

The value is getting displayed.
What is the mistake that I do in pandas.
The number of rows are same in both python and R.

4 Answers

R : %in%
Pandas : isin
Df[Df['A'].isin(['234'])]


#Df[Df$A%in% c('234'),]

Answered by BENY on November 27, 2021

Please use the following code:

df.iloc[1]

Answered by nikhil kuriya on November 27, 2021

234 is probably a string. Try to change it to a float in Python or try

Df[Df['A']=='234']

Answered by Derrick Carr on November 27, 2021

Based on your R code, it looks like 234 is a string. Try:

Df[Df['A']=='234']

Answered by ChairNTable on November 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP