Questions tagged as 'python'

1
answer

Problem with script in Python

People, I have a slight problem with a script I created in Python. print("Agora eu vou dizer algo para você.") idade = int(input("Me diga sua idade.")) if idade < 18 print("Me desculpe, você não pode dirigir.") else print("Que bom, você pod...
asked by 02.07.2018 / 07:17
1
answer

Error reading an .xls file

I have some files to read in Python, I'm using the following structure:    df = pd.read_csv (path, sep = '\ t') And this generated the following error:    UnicodeDecodeError: 'utf-8' codec can not decode byte 0xc3 in position 9: unexpe...
asked by 29.06.2018 / 17:10
1
answer

AttributeError: __enter__ in context manager implementation

I'm trying to understand the workings of Python's gerenciadores de contexto , implementing one based on contextmanager . Here is the script: class contextmanager(object): def __init__(self, func): self._func = func...
asked by 30.06.2018 / 22:41
1
answer

Python Method Resolution Order (MRO)

Let's say I have something like this: # -*- coding: utf-8 -*- class Base(object): @classmethod def foo(cls): pass def grok(self): pass class A(Base): @classmethod def foo(cls): print('A')...
asked by 04.06.2018 / 07:38
2
answers

Is it a good idea to use JSON as a database?

I'm doing a mobile app project. Using Python and Kivy. My project has three main classes to be saved in a database (it's an application for ticket sales): Tickets, Events and Users. Searching, I have seen that JSON at the beginning is quite e...
asked by 23.08.2018 / 00:45
1
answer

How to pass array in a gRPC?

I am testing some codes using gRPC with the Python language, and I am not able to manipulate array. The code consists of passing one vector per parameter, the server receives that vector and sorts.    .proto code syntax = "proto3"; messag...
asked by 15.06.2018 / 23:01
2
answers

Make a random of a dataset with pandas

I'm trying to extract 15O lines from a 500-line dataset. So I would like to do it at random. My Data objeto,cor,label cachorro,branco,animal manga,laranja,fruta calça,preta,roupa My script import pandas import pandas as pd df = pd...
asked by 23.08.2018 / 23:12
1
answer

Limit when creating a list in Python

With the following command, I can create a list in Python: lista = [[None]]*50 I'll have a list of lists with 50 units. However, if I create a list this way: lista = [[None]]*50 for l in lista: l.append([0]*1000) If I give len(...
asked by 12.06.2018 / 20:58
3
answers

Inserted into a list of lists in python

I would like to populate a list where each position is a list. lista = [[], [], []] I have an input: 44 45 49 70 27 73 92 97 95 I would like to list the numbers so that the index is mod of each number by 13. Ex: 44% 13 = 5     27% 13...
asked by 22.06.2018 / 04:35
1
answer

generation of a vector through algebraic operation

I have a "tension" vector with about 30 values inside, to generate a new vector "defo_calculada2" I need to add 0.2 in each value of the "tension" vector, I believe you have a correct way to do this sum in vector < p> defo_calculada2 = tension...
asked by 27.06.2018 / 06:29