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,150 points

edited Jun 9 by MD 801 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 by MD

Related Questions In Data Analytics

0 votes
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 13, 2018 in Data Analytics by Sahiti
• 6,290 points
618 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,080 points
117 views
+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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,075 views
0 votes
0 answers
+4 votes
6 answers
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 by MD 774 views