[Numpy-discussion] np.where and ZeroDivisionError: float division by zero

2024-04-25 Thread 840362492--- via NumPy-Discussion
0

In my code, I use the following calculation for a column in the dataframe: 
np.where(df_score['number'] ! = 0, 100 - ((100 * df_score[rank_column] 
-50)/df_score['number']), None),I have used df_score['number']! = 0, but the 
code is still wrong, ZeroDivisionError: float division by zero, even if I put 
df_score['number']! = 0 changed to df_score['number'] > 0, why?

pandas version:1.1.5 numpy version:1.24.4

Here are my numbers: 12.0 12.0 12.0 12.0 12.0 0.0 
0.0 0.0 0.0 0.0 12.0 12.0 12.0

I want to know why it went wrong and what should be done to fix it? Thank you 
for your help
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: New feature

2024-04-25 Thread Alexei Lisitsa
Waiting for answer
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: New feature

2024-04-25 Thread Matti Picus

On 25/04/2024 23:16, Alexei Lisitsa wrote:


Waiting for answer



What kind of answer would you like? I took a look at numpy_list[0] and 
if it serves your needs, that is great, but I don't think such ndarray 
generation routines should be added to NumPy until they become more 
commonly known, used, and "voted" popular. I would suggest you


- add some examples to the README[1] to demonstrate its utility. I found 
I had to drill down to the code[1] to see what it actually does.


- make it a stand-alone package and not part of NumPy's code base

Matti


[0] 
https://github.com/alessionuovo/mionumpy/tree/list_operations/numpy_extensions


[1] 
https://github.com/alessionuovo/mionumpy/blob/list_operations/numpy_extensions/numpy_list/list_op.py


___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: New feature

2024-04-25 Thread Alexei Lisitsa
Ok, thanks package stand alone I did but how I advertise it?
Maybe you as expert can say some thing that is needed , something to
develop I want some new experience

чт, 25 апр. 2024 г., 23:30 Matti Picus :

> On 25/04/2024 23:16, Alexei Lisitsa wrote:
>
> > Waiting for answer
>
>
> What kind of answer would you like? I took a look at numpy_list[0] and
> if it serves your needs, that is great, but I don't think such ndarray
> generation routines should be added to NumPy until they become more
> commonly known, used, and "voted" popular. I would suggest you
>
> - add some examples to the README[1] to demonstrate its utility. I found
> I had to drill down to the code[1] to see what it actually does.
>
> - make it a stand-alone package and not part of NumPy's code base
>
> Matti
>
>
> [0]
>
> https://github.com/alessionuovo/mionumpy/tree/list_operations/numpy_extensions
>
> [1]
>
> https://github.com/alessionuovo/mionumpy/blob/list_operations/numpy_extensions/numpy_list/list_op.py
>
> ___
> NumPy-Discussion mailing list -- numpy-discussion@python.org
> To unsubscribe send an email to numpy-discussion-le...@python.org
> https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
> Member address: alex123...@gmail.com
>
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: np.where and ZeroDivisionError: float division by zero

2024-04-25 Thread Fang Zhang
The function np.where just chooses elements from two arrays that are both
computed before np.where is even executed. See this StackOverflow answer
https://stackoverflow.com/a/29950752/4681187 if you want to suppress the
error.

On Thu, Apr 25, 2024 at 8:16 PM 840362492--- via NumPy-Discussion <
numpy-discussion@python.org> wrote:

> 0
>
> In my code, I use the following calculation for a column in the dataframe:
> np.where(df_score['number'] ! = 0, 100 - ((100 * df_score[rank_column]
> -50)/df_score['number']), None),I have used df_score['number']! = 0, but
> the code is still wrong, ZeroDivisionError: float division by zero, even if
> I put df_score['number']! = 0 changed to df_score['number'] > 0, why?
>
> pandas version:1.1.5 numpy version:1.24.4
>
> Here are my numbers: 12.0 12.0 12.0 12.0 12.0 0.0
> 0.0 0.0 0.0 0.0 12.0 12.0 12.0
>
> I want to know why it went wrong and what should be done to fix it? Thank
> you for your help
> ___
> NumPy-Discussion mailing list -- numpy-discussion@python.org
> To unsubscribe send an email to numpy-discussion-le...@python.org
> https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
> Member address: fan...@umich.edu
>
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com