zeros()

V

vertigo

Hello

How to create table with string variables ?
I tried

import string
X = zeros([10,10], string)

(i used Numeric.Float earlier, but now can't find string class anywhere)

Thanx
 
J

Jonathan Curran

Hello

How to create table with string variables ?
I tried

import string
X = zeros([10,10], string)

(i used Numeric.Float earlier, but now can't find string class anywhere)

Thanx

I've read that the Numeric module is being replaced/better supported by NumPy.
Anyway, try:

X = zeros ([10,10], str)

I have numpy installed so I did:
from numpy import *
X = zeros ([10,10], str)
X
array([['', '', '', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', '', '', '']],
dtype='|S1')
seemed to work, hope this helps.

- Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top