473,414 Members | 1,626 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

having problem in making matrix in python

I want to make a matrix with 5 rows and 4 columns. The problem is when I run it there appears an error that "Traceback (most recent call last): File "C:\Users\yasini\Desktop\30.py", line 21, in ['ART|Ф',0.71], ['N|Ф',0.29], ['V|Ф',0.0001], ['P|Ф',0]]).reshape(5,4) ValueError: total size of new array must be unchanged".

How can I solve it?

import numpy as np
A = np.array([['ART|ART',0], ['N|ART',1], ['V|ART',0], ['P|ART',0],
['ART|N',0.0001], ['N|N',0.13], ['V|N',0.43], ['P|N',0.44],
['ART|V',0.65], ['N|V',0.35], ['V|V',0.0001], ['P|V',0.0001],
['ART|P',0.74], ['N|P',0.26], ['V|P',0.0001], ['P|P',0.0001],
['ART|Ф',0.71], ['N|Ф',0.29], ['V|Ф',0.0001], ['P|Ф',0]]).reshape(5,4)
print (A)



When I omit the zero from the last cell (['P|Ф',0]), it works right and a 5*4 matrix is produced but when I add zero again this error occurs.
Jun 22 '16 #1
0 1122

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Zoo Keeper | last post by:
>>> class foo(BWindow.BWindow): ... pass ... Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: base is not a class object Not entirely sure what the message means...
8
by: Jan Danielsson | last post by:
Hello all, How do I make a python script actually a _python_ in unix:ish environments? I know about adding: #!/bin/sh ..as the first row in a shell script, but when I installed python on...
4
by: Bucco | last post by:
I installed python 2.5b3 on my windows XP sp2 box without any issues. I can double click the python program, and idle comes up in the command line window. However when I run python from the...
23
by: Python Maniac | last post by:
I am new to Python however I would like some feedback from those who know more about Python than I do at this time. def scrambleLine(line): s = '' for c in line: s += chr(ord(c) | 0x80)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.