Posts by João Victor • 246 points
17 posts
-
0
votes1
answer74
viewsA: assembling 3 dataframes
You can try using the function Concat() pandas. return pd.concat([top_share1, top_share2, top_share3], axis=1)…
pythonanswered João Victor 246 -
2
votes1
answer80
viewsA: Merge array to stay 2 columns
I believe you would like a result 2 x 100, not 2 x 1000. You can do it this way: import numpy as np r = np.array([0.56155503, 0.98218785, 0.95613911, 0.98307298, 0.55173653, 1.04626122, 1.01631092,…
-
0
votes3
answers347
viewsA: Create list with the sum of consecutive equal numbers
lista = [1,2,2,2,3,4,4] def func(lista): resultado = [] soma = lista[0] for i in range(1, len(lista)): if lista[i] == lista[i-1]: soma += lista[i] if i ==…
-
0
votes2
answers80
viewsA: Access to class objects
You’re trying to use the method report in something that is not an object of the Human class. Actually within its if com == 2, you write that name is equal to an input. That is, you are calling the…
-
2
votes2
answers824
viewsA: How do I make the program show all the combinations and then the number of combinations that were formed?
I think adding this line at the end of the code outside the loop works: print(len(permutations(word,len(word)))) Edited: The previous solution does not work, so I would use the same solution of…
pythonanswered João Victor 246 -
0
votes2
answers767
viewsA: Help with code implementation and functions
Man, first I’d like to make some comments about your code: Try to maintain the logic of the names of your variables. Type, you started by putting the names of the variables with initial lowercase…
-
0
votes2
answers7513
viewsA: How can I use the results of one function within another in python
You don’t see anything because you didn’t print it out. Everything you want to see in the terminal needs to be printed out. Your function returns the list, but it doesn’t print. That’s why you don’t…
-
1
votes1
answer45
viewsA: Identifying the most effective method of identifying the central element of a matrix
Man, when it comes to algorithm, you can’t do better. The reason is simple: you have to at least fill 255 each position you want. What you do in the algorithm is go, one by one, filling the matrix.…
-
0
votes1
answer78
viewsA: Doubt in C++ program entry command
You have to pass a pointer to a character, not simply a character, so it looks like this: char *nome;
-
0
votes1
answer130
viewsA: Error using a function outside the Python script
No. You can simply leave the 2 scripts in the same directory, and whatever you run, write in the first line "import Dooutroscript" (without the quotes). For every other script that has functions you…
-
0
votes1
answer983
viewsA: Relationship 1 - 1
Dude, I have two things to tell you. The first is that there is no better way to create a relational model. The second is that there is no right and wrong. When it comes to relational model, you do…
-
2
votes1
answer807
viewsA: How to add an array within a class?
Here’s the thing. There are some errors and practices that are not very good in your code. I’ll try to show you in your own code what I’m talking about. But before that, I’d like to explain…
python-3.xanswered João Victor 246 -
1
votes4
answers94
viewsA: Putting elements in lists
It can be done as follows: lista = ['banana [amarela]\n', 'uva [vinho]\n', 'laranja [laranjado]\n', 'kiwi [verde]\n', 'framboesa [vermelho]\n', 'coco [marrom]\n'] fruits, color = [] for element in…
-
1
votes2
answers1856
viewsA: list index out of range Python
When you are in the list.pop(element), you decrease the list size by 1. So if you had a list of size 10, for example, and you pop it, the list becomes size 9. And when you try to index the tenth…
-
0
votes2
answers82
viewsA: My while closes before what really should
Put a print in in the fibal of the while loop to check if he really isn’t doing all the iterations or if he’s entering this if not and isn’t generating the result you expect.…
-
0
votes2
answers149
viewsA: Web2py - Error using SQLFORM.Factory()
When I try to open web2py it happens Carlos: python web2py.py -a 123 Traceback (most recent call last): File "web2py.py", line 21, in <module> import gluon.widget File…
-
0
votes2
answers149
viewsQ: Web2py - Error using SQLFORM.Factory()
I can’t fix one error that appears when I try to expose a form to two tables of the SQLite. The error is as follows: Traceback (Most recent call last): File…