Posts by Arthur Gouveia • 256 points
4 posts
-
5
votes1
answer1660
viewsA: How to turn diagonal elements of a python matrix into a list
Your question really isn’t very clear. If your matrix is a list of lists, the solution is the following: matriz = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 3, 8, 9], [4, 5, 2, 3, 4, 4], [2, 3, 4, 5, 3, 6], [4,…
-
1
votes2
answers2142
viewsA: Create list with column contents
If you’re using pandas you don’t need to use a for... If you just want to turn projects into a list, do it df.Projeto.tolist() For example: import pandas as pd df = pd.DataFrame({'Autor': ['João',…
pythonanswered Arthur Gouveia 256 -
0
votes1
answer3283
viewsA: Typeerror: only length-1 arrays can be converted to Python scalars
Operations with Numpy arrays are vector arrays. For example: np.array([1, 2, 3]) + np.array([4, 5, 6]) returns array([5, 7, 9]). That way, when you do (x-y)/2 creates a new array and thus the…
pythonanswered Arthur Gouveia 256 -
5
votes1
answer303
viewsA: How to work with more than one python file?
Save the file in the same folder as the original file and you can import it without further problems. arquivo1.py class Classe: def __init__(): .... arquivo2.py from arquivo1 import Classe obj =…
pythonanswered Arthur Gouveia 256