Posts by Lorran Sutter • 428 points
13 posts
-
1
votes1
answer1272
viewsA: Rename files with Python by dynamically adding numbering
Hello, follows a proposal for solution to your problem. To facilitate mainly the file appointment was made the following class: class fileDataModel: def __init__(self, id_name, subject, frente,…
-
2
votes1
answer375
viewsA: Error in Python function ("is not defined")
Hello, Does not work for a simple indentation problem. The way the code is structured, the functions insere_no_inicio and insere_depois are defined within the scope of the class ListaEncadeada.…
-
0
votes3
answers152
viewsA: Separate the result that appears in os.getcwd() to be able to display only c:
Using the function split as stated above, I suggest the following solution: Consider the following directory as an example: d = r"C:\Users\monte\PycharmProjects\Aula3" # OU d =…
pythonanswered Lorran Sutter 428 -
0
votes2
answers42
viewsA: If a function is too long, is it recommended to divide it into smaller ones?
Hello, split a function or not is not always tied to its size, but usually to the processing steps it has. In your example we clearly have repetitive code and that can be separated into smaller…
-
4
votes2
answers206
viewsA: Split Double Python Array
A more simplified way would be: vetor = "0,3 4,5 6,7 10,4 0,3 5,3" coord = [list(map(int,v.split(','))) for v in vetor.split()] print(coord) [[0, 3], [4, 5], [6, 7], [10, 4], [0, 3], [5, 3]]…
-
0
votes1
answer64
viewsA: How to change the content of a qLabel at runtime?
The parameter passed in the QLabel is what will be displayed. So, if you want the number to be displayed, you need to pass this number as a parameter in the form of string. Your code can be changed…
-
3
votes1
answer842
viewsA: Pandas Settingwithcopywarning: A value is trying to be set on a copy of a Slice from a Dataframe
Hello, Guido. Welcome back! That one Warning can be easily solved by modifying your code in this way: for i in range(0,len(NOVOS_ABERTOS_VIVO)): for j in range(0,len(AREA_VERSUS_COLABORADOR)): if…
-
3
votes1
answer3684
viewsA: How to calculate 'end time' in Python?
Hello, welcome! The library datetime is really a good solution to work with dates and times. For example, in the form below we can set the current date and time: import datetime as dt…
-
2
votes1
answer974
viewsA: How to insert a try counter within an exception (except Valueerror) of Python 3
Hello, congratulations on your programming initiative. Your version of the code is well organized and commented on. This is good programming practice. As you are starting out and are creating your…
-
1
votes1
answer187
viewsA: how do I detect on which side is the object if I trace a line the medium
General case 2D: First let’s consider some parameters. The line is vertical and defined by points A and B The object is entirely on one side or on the other side of the line You have the information…
-
1
votes1
answer108
viewsA: How to select codes with different sizes in pandas?
Hello, according to the dataframe information above, the Cpfs you are dealing with are float64, which makes things a little easier. You can make a slice in your dataframe taking only the values that…
-
0
votes1
answer819
viewsA: How to set the xticks equal to that figure
Hello! First of all, there are several different ways to solve these customization problems. Below is a way I usually use and seems more readable. In this case, I have defined a axis where all Plots…
-
2
votes1
answer129
viewsA: Return in a Dataframe - Python
Hello! Assuming that all read files have the same structure, each Dataframe created on else will have the same columns. So, just add the Dataframes read in the result Dataframe in each iteration. #…