r/learnpython • u/dstnmyrs • Feb 29 '20
Actually used python today
I've been learning python for about a month now. I started with automate the boring stuff like so many others have. Since then I have made some small games to practice. I am currently working on a hangman game and needed a list of words to use. I found a list of words and copied the whole thing to a .text file but it came with extra stuff I didn't need. So instead of manually deleting everything I didn't need I made a python script to do it for me. GREATEST FEELING EVER.
393
Upvotes
3
u/[deleted] Feb 29 '20
If you have any regular reporting to do, I have found Python to be a very helpful helper. I use Pandas and Matplotlib to automate a reoccurring report that was quite the waste of time.
Every third week or so I get an Excel spreadsheet of vacation and sick leave balances for approximately 1500 employees from a legacy system. The report gives the first and last name, their salary (but not the hourly wage), the leave balances, and the employee's position number. The position number contains the employee's position job number, and the division and branch they work in (e.g., 123-321-4444), all of which is needed for the final report.
The script I wrote: extracts the position, division, and branch identification, calculates the hourly salary, and aggregates the leave balances according to unit, branch, and division for each level of employee. These aggregations are used to create heat maps for each organizational level with the balances (because management loves heat maps, sizzle sizzle), and then a cheeky little printout using f-strings that describes the heat map or individual employee. For example, there is a heat map of leave balances for all clerical staff in Unit A, all technicians in Unit A, and all Managers in Unit A. Each of these are then rolled up into a heat map for all clerical/technicians/managers in Branch A (which is comprised of Units A, B, C, D, and E), and then rolled up once more for a total of seven-ish Division heat maps. For posterity I use Pandas to create Excel spreadsheets of the individual DataFrames.
To manually accomplish this in Excel, people were spending between 8 and 12 hours across a few days. Via Python, this is completed in under a minute. It takes me longer to email the results to people than it does to do the work.