Questions tagged as 'python'

1
answer

Pandas SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame

I want to copy an element from a dataframe and insert it into another dataframe. In essence there is a dataframe with name x area and another that I need to load with the data of the area, from the comparison of the name in the first datafram...
asked by 18.09.2018 / 03:05
1
answer

How to get a pixel color out of the screen border in pygame?

I know that to get a pixel color in PyGame I use get_at . But I have a huge background image and a good part of it stays outside of the pygame delimited screen area. For example, a 1000x1000 image inside a 500x500 screen will only have...
asked by 21.09.2018 / 01:39
1
answer

Why does not this factorial function work?

def fatorial(n): fat = 1 if n == 0 or n ==1: return 1 else: for i in range(1,n+1): fat=i*fat return fat def main(): n = int(input("Digite um numero que quer ver o fatorial: ")) print(str(n...
asked by 18.09.2018 / 02:42
1
answer

Doubt regarding Python syntax

Good evening, my question is about a piece of code I found in a book about Python and OpenCV. The author created the function that I will put below: @property def frame(self): if self._enteredFrame and self._frame is None: _, self....
asked by 14.10.2018 / 05:10
1
answer

Script in Python via PHP

I am trying to call a script done in Python via browser with PHP. This script has only one command that serves to turn off my Raspberry Pi. PHP looks like this: <?php exec('sudo python /home/pi/Documents/Programa/Script.py'); ?>...
asked by 20.09.2018 / 20:00
2
answers

How to "reimport" an object from a Python module?

I wrote a module called mymodule.py which has the function def funcion(x): return x So I imported this function into a code like from mymodule import function and worked normally. Then I wanted to change the function to...
asked by 27.11.2018 / 17:57
1
answer

Black screen when running a program with Kivy

I do not understand why when I run the following code the screen appears only black. Can someone give me a hand? from kivy.app import App from kivy.uix.label import Label from kivy.uix.button import Button from kivy.uix.floatlayout import Floa...
asked by 04.10.2018 / 17:54
1
answer

Is it valid for two objects to have reciprocal references?

Is this an acceptable practice or is it a gambiarra and should it never be done? Is there any solution to avoid this? It turns out that the object player needs to know the state of the game to be able to play, but the game has it so it would hav...
asked by 11.07.2018 / 19:14
4
answers

Place only the correct message print once

I'm doing this program:    Develop a program that asks you to enter a CPF number   in the format xxx.xxx.xxx-xx and indicate if it is a valid or invalid number through   verification digits and formatting characters. The code is th...
asked by 28.06.2018 / 12:56
1
answer

Code evaluation: Logistic regression with K fold validation. Is correct?

The code below is an attempt to do a logistic regression with k-fold cross-validation. The idea is to take the confusion matrices generated in each fold and then generate a mean confusion matrix with 95% confidence (confidence interval for the m...
asked by 29.06.2018 / 01:36