Skip to main content

All Questions

Tagged with
0 votes
0 answers
89 views

How to efficiently use NumPy's StringDType for string operations (e.g., joining strings)?

I'm trying to perform string operations with NumPy's StringDType. As an example, I've attempted to join strings with a separator row-wise. In the past, NumPy's string operations were somewhat slower ...
Olibarer's user avatar
  • 393
2 votes
1 answer
77 views

Convert numpy float to string

import numpy as np number = np.float32(0.12345678) assert str(number) == "0.12345678" assert f"{number}" == "0.12345678359270096" Why is this different when converting ...
Noushadali's user avatar
0 votes
1 answer
261 views

Converting Byte Array to String Using NumPy Dtype Only. Python

I'm working on a task where I need to convert a byte array obtained from a hexadecimal string into a string representation, utilizing only the specified data type (dtype) in NumPy. Here's what I've ...
Ino's user avatar
  • 21
1 vote
2 answers
69 views

str giving only one element as output but object fix the problem

I have to write a python code, there are a function and it receive a tuple as parameter where all the elements of tuple are numpy array. The output of that code will give me unique hobbies from this ...
Rafitheflash's user avatar
0 votes
2 answers
70 views

Get rid of format string conflict when using sympy

When I try to use sympy to find the derivative of the loss function, it raises a conflict with format string. import numpy as np import sympy as sp def predict(X, w, b): return np.dot(X, w) + b ...
ronzenith's user avatar
  • 393
0 votes
2 answers
114 views

Different behavior of rjust with strings vs numpy strings

I am seeing a difference in behavior in rjust() when used on a string vs on a numpy string. My goal is to fill a number string with 0s. I am seeing a difference in behavior when calling rjust on a ...
kmaps's user avatar
  • 3
0 votes
1 answer
44 views

Switching dataframe integers to string so i can add text like '$' and '5.78 / Million' into the dataframe

I made a dataframe with all the necessary information, however, my manager wants me to remove decimals from all entries except col['REVENUE'] x index['Volume']. Aka keep 5.78 and remove the trailing ...
Rob's user avatar
  • 15
0 votes
1 answer
47 views

Filtering on very large array of 3 possible values

I have a 2D array of 0s, 1s and 2s with very large number of columns. I am trying to select only those rows which have consecutive zeros not exceeding certain number. My method is to convert the array ...
guyguyguy12345's user avatar
1 vote
1 answer
37 views

Add string Column B where string exists in column Columns A + np.where() + pandas

I need to add a secondary ID in a dataset with unique entries for multiple individuals. To do so I am trying to use np.where(), after I implemented I realized I am overwriting the last entry each time....
John Conor's user avatar
1 vote
4 answers
387 views

Why full function in NumPy can't take dtype=str

Why i see just one letter instead of "cube" When i didn't type dtype="str" it worked. My question is why? code: np.full((3,3,3),"cube",dtype=str) results: array([[['c', '...
Necip Arda's user avatar
0 votes
3 answers
75 views

Converting an array of numpy strings into floats with the same sigfigs as string

I want to convert the numpy array ['800' '0' '0.3048' '71.3' '0.00266337'] to float form with the sigfigs shown in the strings. When I tried (with help from this answer X_new = X_tr.astype(float) I ...
Navya Lam's user avatar
0 votes
1 answer
945 views

Is there a way to cast the type of an element in a numpy array to a type that is written in a seperate string

I need to cast the type of an element in a numpy array to another type that is written in a seperate string(for example "int"). I have an assignment to submit and this was one of the ...
Amichai Reznik's user avatar
0 votes
1 answer
2k views

python error UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types

i'm new to python and i'm having an issue executiong this piece of code: import numpy as np DatetimeIndex(['1990-03-31', '1990-06-30', '1990-09-30', '1990-12-31', '1991-03-31', '1991-...
Amel Laref's user avatar
1 vote
1 answer
50 views

np.searchsorted not working properly on netCDF4 array

np.searchsorted is not finding the right indexes but i think it is related to the type of data. To me it looks like this function can't tell floats and strs apart but I can't convert the array to ...
Julieta Rossi's user avatar
0 votes
5 answers
195 views

How to convert a string to numpy array? [duplicate]

Converting string to numpy array Given a string abcxyz, I want it to return a numpy array like: array(["a", "b", "c", "x", "y", "z"]). I ...
xyzf's user avatar
  • 3

15 30 50 per page
1
2 3 4 5
30