+ 4
Multiply a character matrix with int matrix
Which is correct syntax for it? https://code.sololearn.com/cBQxu6JFyr1i
12 ответов
+ 3
"""
Oma Falk you need to specify
dtype="object"
to your string array
"""
import numpy as np
a = np.array([list("word")],dtype='object').T
# or dtype='O'
print(a)
b = np.array([[5]])
print(b)
print(a.dot(b))
[print(*w) for w in a.dot(b)]
print(*list(np.concatenate(a.dot(b)).flat))
+ 3
import numpy as np
n = 5
arr0 = np.array(list('word'))
# 1. repeat
# 2. reshape
arr = np.repeat(arr0, n).reshape(len(arr0), n)
print(arr)
+ 2
Bob_Li I love ❤ you thanks
+ 1
What is the expected output? A matrix with "word" as columns?
As matrix operations are only the defined for numbers, I wouldn't expect it to work with characters. I probably would either repeat and concatenate the matrix or try to use integers instead of characters.
+ 1
I expected
wwwww
ooooo
rrrrr
ddddd
Multiplication between integers and chars is defined. So why not matrix multiplication 😤
+ 1
When I specified the out argument (as an array of string) inside dot method, it raised an error that says "ValueError: dot not available for this type". So I looked for other numpy methods that could work with strings.
np.repeat() method will repeat elements inside numpy array, based on the second argument.
I tried four methods with different output (as I don't know your exact desired output yet). The last two require some list comprehension though, and is somewhat manually multiplied.
https://code.sololearn.com/cAZ9vkJAyt87/?ref=app
0
Maninder singh your reply is off the topic. Please start a new Q&A post to ask your own questions.
I do have a quick answer for you, nonetheless: You misspelled "length".
- 1
How ?
I don't think
- 1
No ,I double check I spelled them correctly
- 2
Function add()
If (arguments.lenght==0){
console.log("no argument found");
};
Else{
console.log(arguments.lenght);
}add(5,6)
Hi guys in this code above there is an error in the line 2 but I did not found
I am trying to prove that if
arguments.lenght==0
Output no arguments found
Else
Output argument.length
Please help me