mathguy

1

votes
0

answer
65

views

numpy.hstack() not working in a jitted function

The numba website https://numba.pydata.org/numba-doc/dev/reference/numpysupported.html says it supports numpy.hstack(). But in practice, it simply doesn't. from numba import njit import numpy as np @njit def func(data):return np.hstack((np.nan, data)) myarray = np.arange(100)*0.1 X =func(myarray) S...
mathguy
1

votes
1

answer
154

views

Oracle db: How to add spaces in specific positions in strings

Suppose I have a string (varchar2) and I want to add a space wherever I have two consecutive a's. So for example: 'graanh' -> 'gra anh'. OK, this is trivial to do, either with replace or regexp_replace. But both choke on three or more consecutive a's. For example: SQL> select replace('aaaaa', 'aa',...
mathguy
1

votes
1

answer
30

views

DataFrame entries got round off when converted to txt

This is what the dataframe looks like before exporting After that it becomes Rounding down is not what I want here; I want the text in txt.file look like what it is shown in the console. So how can I fix this? Any simple solutions?
mathguy
1

votes
1

answer
0

views

Multiprocessing with nested loops and some numpy function calls

I have read some coding examples about multiprocessing and am stil quite confused about it. Here is my contrived example: import numpy as np def data_processing(x,y,z): return np.array([x,y])*(z**0.5) def foo(n1,n2): final_result = {} for i in range(n1): result = np.zeros([n2,n2]) for j1 in range(n2...
mathguy
1

votes
1

answer
31

views

Computationally efficiently convert dtypes of multiple DataFrame columns to one single dtype all at once

the function is the following: def func1(df): df = df.loc[:,['code', 'currentPrice', 'hedgingValue', 'exercisePrice', 'outstanding(%)', 'expiryDate' ]].dropna() df['code'] = df['code'].str[:5] df['currentPrice'] = df['currentPrice'].astype(float) df['hedgingValue'] = df['hedgingValue'].astype(float)...
mathguy
2

votes
3

answer
18

views

Last occurrence of a Groupby object under certain conditions

Let's say I have a DataFrame that looks like this: Categories Values 0 Category 0 1 1 Category 0 0 2 Category 0 -1 3 Category 0 0 4 Category 1 1 5 Category 1 0 6 Category 1 -1 7 Category 1 0 8 Category 2 1 9 Category 2 0...
mathguy
1

votes
2

answer
31

views

Rearrange rows of Dataframe alternatively

I have a dataframe looks like this: df = pd.DataFrame({'col1': [i+1 for i in range(10)] + [-i-1 for i in range(10)], 'col2': ['random string'] *20}) print(df) col1 col2 0 1 random string 1 2 random string 2 3 random string 3 4 random string 4 5 random string 5...
mathguy
1

votes
1

answer
135

views

Numba @jit fails to speed up the performance of this function. Anyway to fix that?

I am quite new to the numba package in python. I am not sure if I am using the numba.jit correctly, but the code just runs too slow with 23.7s per loops over the line: Z1 = mmd(X,Y,20) What is the correct way to optimize the code? I need your help guys. Thank you. Here is my code: import pandas as p...
mathguy
2

votes
0

answer
31

views

Pros and Cons of supplying pdb file to customer

My company publishes a proprietary software component. We have a customer that is having an issue (may be with our product or their application, they don't know) and they've asked us to supply the .pdb file so they can debug. We're hesitant because we want to protect our intellectual property to t...
mathguy