Python 3.10.2 with sqlite3 on Windows 10. Relatively new to Python, but I was quite experienced with Perl around 1997-2005. Banged my head against this for three days. Attacked from lots of angles. No success. I’m asking for guidance, because I don’t see myself progressing on my own at this point without help flipping on the light-switch. My overall application
Convert list of lists with strings into list of dictionaries
I’m trying to convert a list of lists with strings like: Some lists can have multiple string elements, and some of the string elements can have multiple key:values separated by a , like “amenity=high_school,place=city”. My goal is to get a list of dicts, in which the key of each dict could append in list several values from the same key.
Django Model method that uses data from the model
I want to generate unique codes (e.g. “DXGH”) and save it as a field in one of my models. The problem I have is that I do not know how to check against previously generated codes whenever a new object is created. Currently my models.py looks something like this: Ideally I would set the default value of room_code to code_gen_unique,
Method called when an object is deleted
I’m writing a small application in Python 3 where objects (players) hold sets of connected objects of the same type (other players) together with data that belong to the pair of objects (the result of a played game). From time to time it is necessary to delete objects (in my example when they drop out of a tournament). If this
How to add histogram from dataframe in tkinter
I am new to Tkinter and am working on a GUI based on ML. I want to add a histogram plot from a dataframe into Tkinter and am stuck. This is the histogram plot: This is part of my code Pls suggest the correction. Answer You can save the histogram to an image and then open it and display it
How to correctly use Fetch in JavaScript and Django?
I am trying to make a METAR decoder as shown: I am using fetch in Vanilla js and I plan to send the entered code to a Django view. From the Django view, the decoded data will be taken and displayed in the template. views.py urls.py tools.html tool.js I have used the same code for POST using fetch where I
How to create a nest list or a tree view from a flat list based on value condition?
I am working on a problem that given a flat list of strings. But based on the name of the string I would like to create either a nested list, a dictionary or a Node class. Anything that can have a tree structure The string looks something like: [‘big_1’, ‘small_1’, ‘item_1’, ‘item_2’, ‘big_2’, ‘small_2’, ‘item_3’] This should be turned into
creating random values but within another column restraints [python]
I have this type of dataset: I want to have: As you can see, if I just went and created random values for the Gender column, I will eventually have a problem: I might assign different gender names to the same person ID. If I had unique IDs, then, that wouldn’t have been a problem. But I want to create
Python: how to extract the LAST substring of a string with separator into another column?
I have a dataframe with a column “CCR” whose values are as such : “Aaaa;Bbbb;Cccc”, or “Bbbb;;Cccc”, or “Cccc;Bbbb;Aaaa” or just “Bbbb”. I would like to extract the last substring part (after the “;”) and put it into another column “LastCCR”. If there is only one value and therefore no ‘;’ then the value stays the same in the LastCCR
Pandas, convert values of DataFrames into tuple-DataFrame
I have a DataFrame: and a second DataFrame: and i need this two Dataframes to become this one DataFrame: I need nice little tuples, all together in one frame. How is that possible? Answer Create tuples in both DataFrames and join by +: Or join by concat and aggregate by index tuple: