Python: replace nulls with 0 [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
What is the best way to replace all the null "NaN" values in a Python dataframe with the value 0?
Also, is it possible to do this with a for loop?

you can simply use
df.fillna(0)

Related

Python make list from string [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have column with this kind of data:
I want to count how many times valu occur in a row. It is a string, so I want to convert this '63,63,63,63,63,63,63,63,63,63,63' to this ['63','63','63'...].
I there any way to do this quickly?
Thanks
if given string is s
l=s.split(',')
l is the required list

Very new to python, wanting to add a new column named ‘Total’, which is the sum of other totals [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
df['Total']= df.iloc[3:5].sum(axis=1)
returns NaN for some most values, why is this? They are all intergers.
Also is there a better way of doing this?
Check with add with columns slice
df['Total'] = df.iloc[:, 3:5].sum(axis=1)

How to calculate sum of all elements of a list excluding few numbers? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Write a python program to calculate sum of all elements in a list excluding the numbers between 5 and 8.
Take the list as l1=[1,5,3,6,8,9,19,17,14]
sum(x for x in l1 if x not in range(5,9))

Find word in a string where word is not present as a whole instead it's scattered [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need to find a word "little" in a string but word in the string is not present as a whole.
For eg. input string="aalbeiedteetoolpue" or "lliittttllleee"
May be you can try this:
\b\w*l\w*i\w*t\w*t\w*l\w*e\w*\b
Demo

Hi i am trying to get value from the following pattern using python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
the corresponding pattern is ('Handmade Frozen Car', 11.0). I want to get the value as 11.0. Any suggestions are highly appreciated.
x = ('Handmade Frozen Car', 11.0)
secondElement = x[1]
secondElement will be equal to 11.0

Categories