I would like to compare multiple nested dictionaries inside a larger dictionary. Suppose we have the following dictionary: I have a pricesDict that contains the prices of some products (more than 3 as shown above) in different supermarkets (more than 4 as shown above). I want to go through it to compare the n…
Tag: python
Str.format with a list to create filter
Somewhat simple question with many similar ones out there, but I cannot seem to find what I am looking for. I am trying to filter a list of images in a dbc.Carousel via an int list of location numbers. Any image title that starts with a given number will correlate to a location. So, initially, I would want al…
If the username or password is invalid when logging in, how can appear an error on page without refreshing itself, Django
I have a login pop-up and I want after typing wrong username or password to appear a error message, like usual ‘Username or password is incorrect’, but after pressing button on the site, it is refreshing and I need to open my pop-up again in order to see the error, how can I do the error msg to ap…
How to make a __getitem__ method that allows list[][] indexing (2D)
I am trying to make a getitem method where I can use [][] to get an element from and array I have made. The method I came across is this: The problem with this is that I only can access the array by using a tuple, like array[1,0]. What I want is to be able to do this: array[1][0]. Im
Combine dataframes based on multiple conditions in python
Table A Table B Table C These are example tables that represent dataframes that I’m going to create from seperate excel sheets. Basically there’s a many to many relationship going on and I want to be able to create a combined sheet that will roll up the “amount” total (from Table A) fo…
Function with two loops
I want to make a function what must have 2 loops: must check that at least 2 characters (letters) are inserted if the two characters are in the form that the variable must receive at the end, the variable receives the correct orthographic form. Here is my code (but it throws me in infinite loop) [Please be in…
search and find from csv with dict
I have a csv file containing info like this: I also have a dictionary in python containing similar info : how can I search values of dict in my csv file and print matching row in CSV to keys in dictionary in out put for example : Answer Here’s an idea: Create another, inverted dictionary which maps your…
Find if any column in pandas dataframe is NULL and state this in new column
I have a dataframe, something like this I want to create a new column that contains True if any other column is null and False if not. How do I do this? Answer There are 2 functions for that: pandas.isna and pandas.any:
Mayavi: How to modify the point size with points3d mode=point?
I am trying to create images like this one using Mayavi’s points3d: I usually use mode=”sphere”, disable the lighting and adjust the size like that: But for 200K points this takes several seconds to render and some more seconds to write it to disk, which is too slow if you want to do it for …
How to stream DataFrame using FastAPI without saving the data to csv file?
I would like to know how to stream a DataFrame using FastAPI without having to save the DataFrame to a csv file on disk. Currently, what I managed to do is to stream data from the csv file, but the speed was not very fast compared to returning a FileResponse. The /option7 below is what I’m trying to do.…