Posts by Octávio Santana • 401 points
15 posts
-
2
votes1
answer53
viewsA: Error with np.random.suffle, result None
The function np.random.shuffle will just shuffle your dataset and returns nothing, why its variable DataRand is None. What you can do is make a copy and then shuffle the copy if you want to stay…
-
1
votes1
answer388
viewsA: Removing duplicate lines
You can do it like this: lista_duplicada = ['[email protected]', '[email protected]', '[email protected]'] lista_unica = list(set(lista_duplicada)) print(lista_unica) # ['[email protected]', '[email protected]']…
-
0
votes1
answer2959
viewsA: Save csv files to Python after making changes?
Hello, You can concatenate your dataframe to have a single dataframe. For example: df1 = pd.read_csv('arq01.csv') df2 = pd.read_csv('arq02.csv') df3 = pd.concat([df1,df2], ignore_index=True) Then…
-
0
votes1
answer54
viewsA: interface, I want her to save her name and phone in a txt list
Hello, all right? You can do it like this: from tkinter import * class Application: def __init__(self, master=None): self.fontePadrao = ("Arial", "10") self.primeiroContainer = Frame(master)…
-
2
votes1
answer437
viewsA: How to import a function from a module in Python?
It’s the same way you import other modules, as you did in your own code with lib request. Suppose your programs are in the same folder. Let’s call Function.py (suggestion) the code with the…
-
1
votes1
answer130
viewsA: How to create a PDF from a list
So you have to iterate your list, see this simple example from reportlab.pdfgen import canvas listaFinal = ['oi', 'eu', 'sou', 'goku'] pdf = canvas.Canvas("Site_Prefeitura3.pdf") for cont, l in…
-
1
votes1
answer135
viewsA: Merge a dictionary with list inside
Hello, all right? The syntax error is due to you not closing the parenthesis on extend, you can do so in a generalist way: valores = {'valor':[1,2,3], 'valor2':[10,20,30]} valores2 =…
pythonanswered Octávio Santana 401 -
0
votes1
answer52
viewsA: Blank graph
Hello, all right? I circled your code here and the graphs that are blank are just the ones that refer to the trajectory of proton 2 and 3. I did not look in detail at the functions that describe the…
-
2
votes1
answer357
viewsA: Check existence of Python file with function
Hello, all right? So the problem lies in your role cria_arq, you have as argument nome_arquivo however you are checking on if string filename and not the variable itself. See that you have to pass…
-
4
votes3
answers991
viewsA: Showing only pairs in the list - Python
As a curiosity, see another way to solve this problem using filter and lambda lista = list(range(1,1+int(input('Digite o numero: ')))) # Suponha que a pessoa digitou 20. print(lista) #[1, 2, 3, 4,…
-
1
votes1
answer320
viewsA: Change distance on x-axis - Matplotlib
Hello, all right? Before the plt.show() add: plt.xticks(rotation=30) the value 30 means the angle that the Labels will be oriented to with respect to horizantal. This value can be modified.…
-
0
votes1
answer1065
viewsA: sort graphing and fix value in python
Hello, all right? Note that you are sorting the list x and y every time you pass in the is, but it is not necessary to do this, because the data are already sorted by the file you presented above.…
-
0
votes1
answer1052
viewsA: Copy range of values from one Dataframe to another transposed
Hello, all right? You can do as follows, see this example below: import pandas as pd data = [[1,2,3],[3,4,5], [5,6,7], [7,8,9]] col = ['col_'+str(i) for i in range(len(data[0]))] row =…
-
0
votes1
answer140
viewsA: store the data received from a sensor in a python list
Hello, all right? The problem of repetition is due to function criaVetor. In it you add to the list vec the same value tam times. Try adding list values inside while. Take a look at this suggestion:…
-
1
votes1
answer948
viewsA: Sort elements of a python dictionary
First I created a list of the dictionaries you put up. lista = [ OrderedDict([('maquina', 'br'), ('num', '1'), ('projeto', '1809123'), ('var', 'float'), ('reg', '4637'), ('nome', 'teste1'),…
python-3.xanswered Octávio Santana 401