+ 2
Can't filter out something from a column from a dataframe.
Lets say 'df' is a dataframe and 'x' is a column of it. So when I write df['x'] it shows all the elements of that column. There are total 100 elements in that column ( which also mean 100 rows). Now of these 100 values 90 are float and 10 are NaN. I want to write a simple line of code which will filter out the NaN values and will show the 90 values which are float. I tried writing below ones but not working: 1. df[dtype(df['x'])==float64)] 2.df[df.x.dtype==float64] Nothing is working. What is the proper way to write the code?
2 ответов
+ 4
Thank you 《 Nicko12 》 it was a simple solution. I couldn’t think of it. I need to observe more.
+ 2
You can use mask to filter and compare values or types.
Here's an example
https://code.sololearn.com/chhbNozbPf01/?ref=app