I have a DataFrame df1 :
df1.head() = wght num_links id_y id_x 3 133 0.000203 2 186 0.000203 2 5 6 0.000203 2 98 0.000203 2 184 0.000203 2
I need to compute a variable called thr ,
thr = N*(N-1)*2,
where N is the number of lines df1 .
The problem is that when I calculate thr , Python returns a negative value (although all inputs are positive):
ipdb> df1['wght'].count()*(df1['wght'].count()-1)*2 -712569744
Possible hint
The number of rows N is
ipdb> df1['wght'].count() 137736
hence,
ipdb> 137736*137735*2 37942135920.
Whereas the maximum value that can be assigned to int32 is 2147483647 , I suspect that NumPy considers type(thr) = <int32> when it should be <int64> . Does this make sense?
Please note that I did not write the code that df1 generates, because
ipdb> df1['wght'].count() 137736
However, if necessary to reproduce the error, let me know.
Thanks in advance.
source share