How to drop rows of Pandas DataFrame whose value in certain coulmns is NaN

0 votes

I have a DataFrame:I want to remove this NaN value row without dropping it?

May 7, 2018 in Data Analytics by DataKing99
• 8,250 points

edited Jun 9, 2020 by MD 1,660 views

1 answer to this question.

0 votes

Hi@DataKing99,

You can create one function according to your requirement. Here I am sharing one example based on your dataset.

def fun(price):
    val = price
    if pd.isnull(val):
        return ""
    else:
        return val
data['Price'] = data['Price'].apply(fun)

You will get the below output.

Distance Price
0 2 20
1 4 40
2 7
3 9 90
4 10

You can return any value to replace your NAN according to your requirement.

answered May 7, 2018 by DeepCoder786
• 1,720 points

edited Jun 9, 2020 by MD

Related Questions In Data Analytics

+1 vote
2 answers
0 votes
1 answer
+1 vote
1 answer

How to convert a list of dataframes in to a single dataframe using R?

You can use the plyr function: data <- ...READ MORE

answered Apr 14, 2018 in Data Analytics by Sahiti
• 6,370 points
6,852 views
0 votes
1 answer

How to limit output of a dataframe in R?

For randomly sampling a row/cell where a ...READ MORE

answered Apr 18, 2018 in Data Analytics by kappa3010
• 2,090 points
3,223 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,348 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,906 views
0 votes
7 answers
0 votes
1 answer

How to delete DataFrame row in pandas based upon a column value?

You can use drop function in your ...READ MORE

answered May 3, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 9, 2020 by MD 1,587 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP