Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Sorting Steps
Post: RE: Sorting Steps

Following your private message: 1. It seems a bit strange to me to check your sort method by using sorted(). If you have already sorted, why do it again? 2. Why make life difficult by adding 0 at the...
Pedroski55 General Coding Help 11 342 Yesterday, 09:34 AM
    Thread: Compare current date on calendar with date format file name
Post: RE: Compare current date on calendar with date for...

You should read about the Python module datetime. Here is a good start You can get the dates from your file names and today's date like this: from datetime import date, time, datetime filename = '2...
Pedroski55 General Coding Help 1 121 Mar-26-2024, 08:23 AM
    Thread: Dataframe copy warning
Post: RE: Dataframe copy warning

Sorry, the arithmetic was off! .size is a reserved word/function, I wasn't aware of that! result.size will give the number of data in the dataframe, use result['size'] values = result.price * result...
Pedroski55 General Coding Help 4 183 Mar-25-2024, 12:16 PM
    Thread: Dataframe copy warning
Post: RE: Dataframe copy warning

Maybe try like this: import pandas as pd xlfile = '/home/pedro/myPython/pandas/xl_files/weight_X_price.xlsx' df = pd.read_excel(xlfile) # get a subset based on condition boolean_series = df['weight'...
Pedroski55 General Coding Help 4 183 Mar-25-2024, 09:01 AM
    Thread: Tkinter & Canvas
Post: RE: Tkinter & Canvas

Not an answer, but a problem: I was interested, so I set: img = '/home/pedro/Pictures/aphrodite.jpg' Trying out the code, I am getting: Quote:Main().mainloop() Traceback (most recent call last): ...
Pedroski55 General Coding Help 5 263 Mar-24-2024, 06:25 PM
    Thread: Frog Puzzle Random To Custom
Post: RE: Frog Puzzle Random To Custom

Following your private message: I think perhaps you are concentrating on a list with only 4 elements, but that is not helpful. You need to be able to sort any list. Try this way to bubble sort: f...
Pedroski55 General Coding Help 4 292 Mar-24-2024, 06:14 PM
    Thread: Frog Puzzle Random To Custom
Post: RE: Frog Puzzle Random To Custom

I think what you want to do is a bubble sort. Or maybe you want to know how sorted() works? Your code doesn't work and seems complicated. This implementation of the bubble sort may help you visualis...
Pedroski55 General Coding Help 4 292 Mar-24-2024, 07:57 AM
    Thread: Copy xml content from webpage and save to locally without special characters
Post: RE: Copy xml content from webpage and save to loca...

@snippsat I like to try out advice from experts, to see how it works. I tried your code, but what I get is an almost exact copy of my webpage. The output has more lines, because every html tag is o...
Pedroski55 General Coding Help 14 597 Mar-22-2024, 06:45 AM
    Thread: How to include one script into another?
Post: RE: How to include one script into another?

A stab in the dark without more info, but: If they are not too big and complicated, why not try defining the 3 scripts as functions in 1 Python file? import everything needed paths = ..... var = ....
Pedroski55 General Coding Help 8 305 Mar-21-2024, 06:57 AM
    Thread: How to include one script into another?
Post: RE: How to include one script into another?

A stab in the dark without more info, but: If they are not too big and complicated, why don't you define the 3 scripts as functions in 1 Python file? import everything needed paths = ..... var = .....
Pedroski55 General Coding Help 8 305 Mar-21-2024, 06:46 AM
    Thread: automatic document renaming
Post: RE: automatic document renaming

I made a docx with a table, saved it also as PDF. Assuming: 1. you only have 1 table per document, or the info you want is in the first table 2. the name is in row 1 column 2 in the table, this get...
Pedroski55 General Coding Help 2 275 Mar-20-2024, 06:34 PM
    Thread: list.sort() returning None
Post: RE: list.sort() returning None

Just joking, no harm meant. This link shows the quote. On the first page, down a little.
Pedroski55 General Coding Help 8 406 Mar-19-2024, 03:46 PM
    Thread: list.sort() returning None
Post: RE: list.sort() returning None

**smile** **smile** **smile** Dead_EyE: a very accurate shooter (and reader?) Quote:You can also use the list.sort() method. It modifies the list in-place (and returns None to avoid confusion). ...
Pedroski55 General Coding Help 8 406 Mar-18-2024, 10:39 AM
    Thread: FTP Download of Last File
Post: RE: FTP Download of Last File

Not Python, but very handy! Assuming you can ssh into your server, a bash script is good for doing file things like you want. This lovely little 1-liner from stackoverflow 2010 gets you the name of ...
Pedroski55 General Coding Help 4 289 Mar-16-2024, 09:15 AM
    Thread: TypeError: unhashable type: 'Series'
Post: RE: TypeError: unhashable type: 'Series'

Try like this: df = pd.read_csv("/home/pedro/myPython/pandas/csv_files/get_data_by_date.csv") date = input("What date would you like to view? (dd/mm/yyyy)\nEnter: ") date # returns '03/09/23' df['Da...
Pedroski55 Data Science 2 293 Mar-14-2024, 03:36 PM
    Thread: WebElements of an HTML page
Post: RE: WebElements of an HTML page

Whatever you want to do, 99.99% of the time, someone has already done it. stackoverflow.com is a good place to look! Why not parse a very simple .html file on your computer first, to see how to do th...
Pedroski55 General Coding Help 2 264 Mar-13-2024, 10:23 AM
    Thread: Weight Distribution
Post: RE: Weight Distribution

Post a bigger Excel then maybe I can help.
Pedroski55 General Coding Help 11 511 Mar-13-2024, 06:08 AM
    Thread: break print_format lengthy line
Post: RE: break print_format lengthy line

Change the input to keep it short and sweet? infos = [('Ali', 3), ('Mohammed', 2), ('Kent', 5), ('Barbie', 0)] for i in infos: print('{} is in classroom: {}.'.format(*i)) for i in infos: prin...
Pedroski55 General Coding Help 4 275 Mar-12-2024, 03:26 PM
    Thread: Weight Distribution
Post: RE: Weight Distribution

The Excel you posted was what I needed! myApp() below will get what you want, but it is not flexible, because, for Banking , the first step uses SUM($D$2:$D$3)/SUM($E$2:$E...
Pedroski55 General Coding Help 11 511 Mar-12-2024, 12:41 PM
    Thread: Weight Distribution
Post: RE: Weight Distribution

Quote:Second Step: Since insurance in Level_3 group does not have any value in child_weight, parent_weight value gets divided among all rows which has same Level_2. All 5 rows have Financial in Level...
Pedroski55 General Coding Help 11 511 Mar-11-2024, 06:01 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020