Questions tagged [python-3.x]

Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 3 interpreter only. Do not mix this tag with the python-2.x tag.

Filter by
Sorted by
Tagged with
3 votes
1 answer
116 views

The shortest path between airports

Airlines need to provide their customers with flights to every corner, so they need an app that allows them to do so. The customer must be able to transfer when there is no direct connection. The ...
user avatar
0 votes
1 answer
39 views

Comparing custom Geometry classes (Lines and Planes): How to increase the accuracy of the __eq__ method

I'm creating custom classes to represent Planes and Lines on a 3d graph. To help improve the performance of my process I've started implementing __eq__ so that I ...
user avatar
1 vote
1 answer
45 views

Systems of equations solver with sympy

So this is my first Python project and hoped for a bit of feedback. I'm trying to make a little program, where I can insert n equations and run a numerical solve. I ended up using tkinter for the GUI ...
user avatar
2 votes
1 answer
68 views

dataframe mean outliers to NaN to derive a higher quality mean for area,speed,azimuth

I have some data that represents the area, speed(meters per second), and azimuth(rads) of a polygon. The objective is to determine the mean for each set of parameters. With that mean value, apply a ...
user avatar
2 votes
1 answer
59 views

Finding the modal hue of an image

As part of my first python project, I needed to know what the dominant hue of an image was. I started with finding the modal hue of the image, but the results seemed really odd in images with pale/...
user avatar
  • 163
3 votes
0 answers
66 views

Scraping housing dataset row by row from Estate Agent's website

I have written web scraping code with selenium with python3 for a dynamic site (it was my first project that is why I started with selenium). In my code I extracted the values and created DataFrame. ...
user avatar
3 votes
2 answers
76 views

Reformatting strings according to different properties with OO

I had to write a cycle that loops a log file and assigns a given status according to some logic. I didn't post the whole code but this is the script that bugs me the most... why? Well, first: I ...
user avatar
2 votes
0 answers
42 views

Python data entry into excel based on equality check with dataframe

My objective is to enter/type in values into Excel cells if the column names and indices match between Excel and dataframe. So, my code does the below Gets the ID values from the dataframe for each ...
user avatar
  • 235
4 votes
2 answers
58 views

Search for providers of TV Shows

All my code is below. It uses an API to search for a show and then outputs the providers (like breaking bad is available on Netflix). The main aim of this application was to practice using APIs and ...
user avatar
  • 41
1 vote
1 answer
39 views

numpy mean azimuth with functools.reduce

From the left to the right column calculating the mean azimuth, and using that mean value to calculate the subsequent columns mean value data (azimuth radians) ...
user avatar
2 votes
1 answer
51 views

follow-up - Checking Nested Bracket Levels in Strings Programming Challenge

A follow-up to this question, this post improves on test case issues. To restate problem parameters, a given string S is considered closed if it: Has a matching ...
user avatar
  • 2,897
3 votes
2 answers
168 views

Programming Challenge - Capturing Bracket Levels

I don't have a formal description for this problem, but here are the parameters: Given a string S check that each opening bracket has a matching closing bracket. ...
user avatar
  • 2,897
3 votes
0 answers
33 views

Python Script that searches a corpus for most relevant results according to search terms

I am currently working on building a small search engine (if it can be called that) that allows users to search for relevant articles from a short list of other older websites that do not have search ...
user avatar
  • 31
0 votes
1 answer
49 views

Sorting nested dictionary by price - without extra memory

I am working on parsing an orders.csv file with products and prices by different vendors which is kind of a time-series data. The output of that process looks something like below, with order total by ...
user avatar
2 votes
2 answers
165 views

Create csv file for each id value and write all data rows to csv with same id

I have a text file which is tab delimited: 1 324 2344 1 8372 1234 2 62 12 2 872 12111 2 1211 28736 3 87636 198272 The first &...
user avatar
  • 23
2 votes
2 answers
64 views

Programming Challenge: Python 3 DNS query resolver using socket

This is a DNS query resolver written in Python 3 using socket, I wrote it entirely by myself, it supports 8 primary DNS query types: A, NS, CNAME, SOA, PTR, MX, TXT,...
user avatar
3 votes
1 answer
101 views

pandas dataframe of temps and numpy.linalg.lstsq

The problem is this. Forecast model data indicates at 0700Z the 1000 milibar temps will be -4C°. The forecaster knows that is incorrect, so they choose to make a correction. This correction should ...
user avatar
0 votes
0 answers
76 views

Load license plate data from Excel

The code below gets data from an Excel spreadsheet and returns some values; this can take up to 15 minutes because the Excel has more than 15 columns and an average of 20,000 rows. ...
user avatar
  • 11
2 votes
1 answer
169 views

Programming Challenge - Game Scoring

Can this solution be made more efficient? game_scoring.py ...
user avatar
  • 2,897
3 votes
1 answer
47 views

Weighted Union-Find class

For a final project I used a weighted union-find and decided to implement it in Python. I wrote it to be as general as possible so it's very portable. I do plan on looking into path compression to ...
user avatar
1 vote
1 answer
56 views

Ising Model simulation in Numpy

I've written this code to simulate the Ising Model. The idea is a system represented as a matrix with each element having value 1 or -1. The input is an initial matrix of 1 and -1; it is then being ...
user avatar
2 votes
1 answer
35 views

Python snippet for bulk moving files into their parent folder

I wrote this little snippet which moves files from several subfolders to their parent folder. Since the snippet uses different nested for loops I was wondering if it could be refactored to a cleaner ...
user avatar
4 votes
1 answer
100 views

Modeling global warming with a sinusoidal fit in Python

I would like to model global warming from temperature records recorded daily from June 1920 to October 2019 in Montélimar on Python. To do this, I would first like to model these seasonal variations ...
user avatar
  • 41
1 vote
1 answer
38 views

Synchronization \ backup of directories and files (Python)

stackexchange members. I'm just learning to write. I set myself a task a few days ago and today I completed its implementation. The task was to create a "backupper" (I was inspired just by ...
user avatar
2 votes
1 answer
116 views

Parse a log file into separate column files

This is a follow-up to https://stackoverflow.com/questions/71194832/converting-json-based-log-into-column-format-i-e-one-file-per-column . My task is to optimize this code whose function is to convert ...
user avatar
11 votes
2 answers
639 views

Calculator using variable names

I've recently been assigned an assignment to create a word calculator, and given my knowledge in python is still quite lacking, I want to ask if anybody has any better ideas for any possible solutions....
user avatar
5 votes
2 answers
430 views

Sort a Python list of strings where each item is made with letters and numbers

I have a set of strings that all consist of one or two letters followed by one or two digits. I need to sort by the letters then by the numeric value of the digits. My solution is quite inefficient ...
user avatar
  • 799
6 votes
2 answers
938 views

Comparison function returning -1, 0 or +1

I was solving this: Write a compare function that returns 1 if x > y, 0 if x == y, and -1 if x < y. Writing the code, it seemed that after the first if ...
user avatar
7 votes
2 answers
542 views

Function that checks Fermat’s Theorem for a set of values

This is a challenge from Think Python 2nd Edition: Fermat’s Last Theorem says that there are no positive integers a, b, and c such that aⁿ + bⁿ = cⁿ. for any values of n greater than 2. Write a ...
user avatar
4 votes
0 answers
124 views

A skinny json-sql modeller targeting PostgreSQL

Over the last year, I have been slowly building an abstract class for deserialisation, and it has sort of morphed into a lightweight JSON-SQL modeler targeting PostgreSQL with ...
user avatar
  • 45
1 vote
0 answers
166 views

Python Wordle solver

I created a Python script that solves Wordle (more specifically this version: https://mywordle.org), it uses a wordlist of all possible answers, it is working perfectly and it rarely loses, you can ...
user avatar
6 votes
1 answer
400 views

LFU Cache implementation in Python 3

Need some feedback on this implementation of LFU cache in python3. Original problem : https://leetcode.com/problems/lfu-cache/ Would really appreciate some feedback on readability, understandability ...
user avatar
  • 63
3 votes
1 answer
130 views

Vincenty's distance Direct formulae numpy

I've refactored a function from the pygc library used to generate the great_circle. The Vincenty's equation below can be found ...
user avatar
3 votes
1 answer
289 views

Python function to output a string that is justified to the right

I just solved this exercise from Think Python, 2nd edition: Python provides a built-in function called len that returns the length of a string, so the value of len('allen') is 5. Write a function ...
user avatar
0 votes
1 answer
74 views

Outputting a graphic using functions

How would you make this piece of code more simple/efficient? The problem should not be solved with one print statement, rather with functions Could you also give me any advice how I can come to your ...
user avatar
2 votes
1 answer
109 views

Finding the next palindrome number

I wrote a piece of code that generates the next palindromic number and that works fine. However I feel like my code isn't as efficient as it could be. Are there any tweaks that I could implement to ...
user avatar
  • 41
9 votes
1 answer
916 views

Python script to analyse Apache log files

I am fairly new to Python programming language. Most of python programmers have heard the philosophy behind the python programming language. The code should be easy to read, easy to understand, simple,...
user avatar
0 votes
0 answers
22 views

Testsuite for implementation of the command pattern

I've attempted to introduce the command pattern for my use-cases. I would like some feedback on my Test suite. I've tried to delegate as much responsibility to other classes/functions so the primary ...
user avatar
  • 163
4 votes
1 answer
38 views

Exporting a merged dataset from multiple source to a downloadable link

I'm working on a use case in hobby project where I am merging data from an external data source with an internal one and exporting that to a downloadable file The use case is exposed in an ...
user avatar
  • 163
2 votes
0 answers
42 views

CodeReview: CycleGAN Implementation Using Keras FunctionalAPI

Okay So I Am Here Implementing the cyclegan architecture with using keras api from scratch. For Those who Wanna Know More About Cyclegan seehere The CycleGan Compose of Two Phase Architecture Like ...
user avatar
2 votes
1 answer
72 views

Encode non-negative integer to a string of ascii letters and digits

I want to encode a non-negative integer to ASCII letters and digits. I wrote below code for that, that works, but which I assume too immature to use in production. ...
user avatar
4 votes
1 answer
107 views

pandas conditions across rows and columns

Is there a better way to accomplish this? The function determines the Category for each row based on some conditions. Another set of conditions determines the <...
user avatar
2 votes
1 answer
88 views

Python functions that calculate first n terms of a given order of Fibonacci sequences

I have written two functions that calculate the first n terms of a given order o of Fibonacci sequence, and return the result as ...
user avatar
4 votes
2 answers
127 views

OOP Matchsticks Game [Update]

I made the changes that were suggested to improve the program in the previous version. I would like to know if it is decent now or is there something to tweak. ...
user avatar
8 votes
2 answers
475 views

File Concordance

I am working on this Python project, and I pretty much have it done, I just wanted to get a second opinion, to make sure it looks good, and to see if anyone had any tips for it. I also was a little ...
user avatar
2 votes
2 answers
52 views

Calculates start time and end time of jobs in a dataproc cluster

I have the below function get_status_time which calculates the start time and the end time of the spark job which has already completed its run (status could be ...
user avatar
  • 55
7 votes
2 answers
365 views

Rock, Paper, Scissors game in Python with OOP

I am still practising object oriented programming and I decided to do the rock-paper-scissors game as a project. I listen to constructive criticism to improve the program. ...
user avatar
5 votes
4 answers
1k views

Get random time between two time inputs

This code takes two times as input and then calculates a random time between the two inputs. ...
user avatar
0 votes
0 answers
20 views

Python selenium online Stanford-Binet Test solver

This is a Python program that solves a version of Stanford-Binet Test found at https://stanfordbinettest.com, basically it is a selenium bot that goes to the test url and submits what I have ...
user avatar
8 votes
1 answer
104 views

Scrape a URL for articles to save

Below is an exercise project I was doing on a certain educational site. It is supposed to parse a given (static address in this example) URL for html data, search articles of a given type there and ...
user avatar