string « numpy « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » numpy » string 

1. more efficient way to pickle a string    stackoverflow.com

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 ...

2. Longest string in numpy object_ array    stackoverflow.com

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 ...

3. Write a data string to a numpy character array?    stackoverflow.com

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', '', '', '', ''],
       ...

4. String preallocation in numpy.arrays    stackoverflow.com

>>> 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 ...

5. numpy.equal with string values    stackoverflow.com

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 ...

6. Fastest way to generate delimited string from 1d numpy array    stackoverflow.com

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 ...

7. converting python list of strings to their type    stackoverflow.com

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", ...

8. How do I create a numpy array from string?    stackoverflow.com

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 ...

9. Clustering ~100,000 Short Strings in Python    stackoverflow.com

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 ...

10. Filling numpy array using [:,:] crashes python?    stackoverflow.com

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 ...

11. NumPy: load heterogenous columns of data from list of strings    stackoverflow.com

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 ...

12. Where is the NumPy version string documented?    stackoverflow.com

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.

13. How to assign a string value to an array in numpy?    stackoverflow.com

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>
  ...

14. Converting a list of strings in a numpy array in a faster way    stackoverflow.com

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 ...

15. Applying string operations to numpy arrays?    stackoverflow.com

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 ...

16. Numpy with strings!?! is it possible?    python-forum.org

17. Efficient numpy to string conversion    python-forum.org

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 ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.