The pickle module seems to use string escape characters when pickling; this becomes inefficient e.g. on numpy arrays. Consider the following
z = numpy.zeros(1000, numpy.uint8)
len(z.dumps())
len(cPickle.dumps(z.dumps()))
The lengths are 1133 characters and 4249 characters ... |
I'm using a numpy object_ array to store variable length strings, e.g.
a = np.array(['hello','world','!'],dtype=np.object_)
Is there an easy way to find the length of the longest string in the array without looping ... |
I want to write a data string to a numpy array. Pseudo Code:
d=numpy.zeros(10,dtype=numpy.character)
d[1:6]='hello'
Example result:
d=
array(['', 'h', 'e', 'l', 'l', 'o', '', '', '', ''],
...
|
>>> import numpy as np
>>> a = np.array(['zero', 'one', 'two', 'three'])
>>> a[1] = 'thirteen'
>>> print a
['zero' 'thirt' 'two' 'three']
>>>
As you can see, the second element has been truncated to the maximum ... |
The numpy.equal function does not work if a list or array contains strings:
>>> import numpy
>>> index = numpy.equal([1,2,'a'],None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function not ...
|
I have a program which needs to turn many large one-dimensional numpy arrays of floats into delimited strings. I am finding this operation quite slow relative to the mathematical operations in ... |
given a list of python strings, how can I automatically convert them to their correct type? Meaning, if I have:
["hello", "3", "3.64", "-1"]
I'd like this to be converted to the list
["hello", ...
|
|
I have a file reader that reads n bytes from a file and returns a string of chars representing that (binary) data. I want to read up n bytes into a ... |
I want to cluster ~100,000 short strings by something like q-gram distance or simple "bag distance" or maybe Levenshtein distance in Python. I was planning to fill out a distance ... |
Greetings,
I have come across an interesting error and was wondering if anyone knew the cause.
I create several numpy arrays of dtype object and wish to initialize them with empty strings, so ... |
I'm working with array data stored in an ASCII file (similar to this thread). My file is at least 2M lines (158 MB), and is divided into multiple sections ... |
What are the possible NumPy version strings? What is the standard? Where is this documented?
1.4.0dev7059
1.4.0b1
1.4.0rc2
I've seen dev, b, rc.
|
When I try to assign a string to an array like this:
CoverageACol[0,0] = "Hello"
I get the following error
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
...
|
br is the name of a list of strings that goes like this:
['14 0.000000 -- (long term 0.000000)\n',
'19 0.000000 -- (long term 0.000000)\n',
'22 0.000000 -- (long term 0.000000)\n',
...
I am ... |
Are there better ways to apply string operations to ndarrays rather than iterating over them? I would like to use a "vectorized" operation, but I can only think of using map ... |
|
Hi all, I need to convert a numpy array into a string format, and at the moment my challenge is to make my program run much faster. My numpy array is of this kind: pop_A=[[99 200 300 400 500 599] [101 200 300 400 500 600] [98 200 300 401 500 599]..... and I need my string to look like that ... |