I have tried to containerize my python code , this is working, building the docker image, running the container and invoking the python code in my app.py file. next, i want to be able to upload the sample.txt file that my python code reads from the root of the application to process some data, sample.txt in t…
Tag: python
Error in the installation of tesseract ( pycharm python)
I have installed open-cv, jupyter … But i have problems with tesseract. I have installed tesseract application but i can’t install this on pycharm. Someone can help me? Answer First you need to install the executable file. The link of downloading executable file on windows: https://github.com/UB-M…
How to cross-reference data in Pandas dataframes?
I’m working with data that has two separate IDs per item. When we pull data from most sources, we get a PLU/SKU—however, in one of our sources, we get an item number from our on-prem point-of-sale system. To solve this by hand, we have a master list that contains both the PLU and item number for each it…
Access Django M2M values in queryset without looping
I receive some data through Ajax that allows me to do some filtering on a model that has some m2m relations (say Model). I get a queryset, say “content” that I then need to send back using json. Here are simplified lines of code: It was working fine but the project changed and I now need to includ…
How can I merge aggregate two dataframes in Pandas while subtracting column values?
I’m working on a rudimentary inventory system and am having trouble finding a solution to this obstacle. I’ve got two Pandas dataframes, both sharing two columns: PLU and QTY. PLU acts as an item identifier, and QTY is the quantity of the item in one dataframe, while being the quantity sold in ano…
Minimal Flask app unreachable from Docker container
I have a very simple flask service that I’m trying to run inside a docker container. I used python to implement a minimal application that is working fine on my Windows, but isn’t reachable when inside a Docker container. I tried the common fix of setting –host=0.0.0.0 (tried multiple ways),…
QCombobox in a QDataWidgetMapper does not update model when using QSortFilterProxyModel on QSqlRelationalTableModel
I have a setup that uses a QTableView with a QSqlRelationalTableModel and a QDataWidgetMapper to edit the values of the active row in the table view: Everything works as expected when I set the QRelationalTableModel instance as the view’s model. But when I use the proxy model, as above, changes in combo…
python find the nearest nonzero element in df column
I have df: I want to write a function to fill 0 values.I want for each id(for each group) , when the value in number column is zero, to search the closet non zero value in the column and return the value. for example to id 1 to fill the second and third-row with 2. If I dont have such
Find words in array and get their indexes in Dataframe in Pandas
I have a dataframe : I need to find words from column token_1 in token_2 and get their indixes in an array. Then get a list of indexes for each line, i expected this: Answer Use list comprehension with enumerate for indices:
regex to find a string or another string in search and then return one part of the searched with group
I have a string which is a file name, examples: I want to find a string with re.search which corresponds to Fddd or FSC-ddd. I have a regex like this: Later after I have found for example FSC-814 , I want to get only the number from this found string, I used: but it does not work after I included