Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
Cómo crear una matriz de 3 X 3 con todos los que están en ella usando NumPy

Soy un aprendiz, un poco atascado con eso. No entiendo cómo creo debajo de la matriz 3 X 3, todos los 1 estarán en ella.

 1 , 1 , 1 1 , 1 , 1 1 , 1 , 1

Mi código :

 import numpy as np arr=np.ones(np.full(1)).reshape(3,3) arr
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

si quieres usar reshape() :

 import numpy as np arr=np.ones(9).reshape(3,3)

o directamente:

 import numpy as np arr=np.ones(shape=(3,3))

o de otra matriz:

 import numpy as np arr1=np.array([[1,2,3],[4,5,6],[7,8,9]]) arr2=np.ones_like(arr1)

leer documentaciones ( enlace )

forma: forma de la nueva matriz, por ejemplo, (2, 3) o 2.

si desea 1 en lugar de 1. establezca argumant dtype = int

dtype: El tipo de datos deseado para la matriz El valor predeterminado, Ninguno, significa

over 4 years ago · Santiago Trujillo Report

0

¿Qué pasa con esto?

 >>> np.ones((3,3)) array([[1., 1., 1.], [1., 1., 1.], [1., 1., 1.]]) >>> np.ones((3,3)).dtype dtype('float64')

si int

 >>> np.ones((3,3), dtype='int') array([[1, 1, 1], [1, 1, 1], [1, 1, 1]])
over 4 years ago · Santiago Trujillo Report

0

Tratar

 import numpy as np np.ones((3,3))
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!