Say I have a column which has values like: I would like the piece of code that I am working on to return: I’m trying to get the code to sort this key-value pair based on the value of the item in descending order This is the code I have written as of now, but it’s sorting based on the
Trying to keep the same type after saving a dataframe in a csv file
When I try to get my dataframe out of the csv file the type of the data changed. Is there a way I can avoid this? Answer csv files does not have a datatype definition header or something similar. So when your read a csv pandas tries to guess the types and this can change the datatypes. You have two
Azure Form Recognizer error Atribute error when making the request
I’m trying to follow this document for the form recognizer API, specifically the example for Recognize receipts: I’m trying the following code: And getting this error: The difference I see is that in the example the endpoint and key are called as attributes of a class: But I do not see where does …
openpyxl and iteration + alter specific cells question/seeking resource
Very new to python here. Need some help with using openpyxl, please! This is for a personal project on my self-learning journey. I’m looking for a resource to show me how to do the following thing in pip3 openpyxl: I have a class that has a variable which acts as a unique identifier. This is the first c…
Can’t i use the variable in a formula?
I’m coding a math model using gurobiy, but an error occurs. the error is ‘Var’ object cannot be interpreted as an integer. i tried to solve it using search, but I don’t have enough information. spi: required space of block i cft: area of factory f at t time s_Time : Start time p_Time :…
How to convert two different date formats from a pandas dataframe column into same format?
I have two different date formats in a pandas column such as – DD-MM-YYYY and MM/DD/YYYY and I want to convert them into the same format. I tried using the code – but this converts the dates into DD/MM/YYYY and MM/DD/YYYY into the output – data[‘SALE DATE’] I want a python soluti…
Concatenate three inputs of different dimensions in Keras
I have two inputs of same size and then applied word embeddings of vector size 128 and then reshape it giving both inputs shape of (none,1,128), another input which is context has dimension (none,1,18), I want to concatenate these three inputs and then feed the combined output to an LSTM layer. But I am unabl…
Why is there no module named queue in PyPy?
I need to use PyPy because speed is of the essence. I want to use priority queue and normally with Python I’d use queue module but PyPy gives me an error. error: Why is this module not available? I thought that PyPy is compatible with Python’s standard library. Answer Thanks to @user2357112support…
Problem with loading a json file for geo_data in python
I am currently trying to use folium library in python to create webmaps. I have a file world.json which contains geo_data. I have provided a link to the file at the end of this post. I tried the following code: and received the following error: How can I load this file? What I want to achieve is essentially o…
How to get rid of r n and elements in a string
I’ve web scraped addresses and the address strings have unwanted elements like “n” and “<br/>”, how do I remove them? Answer You can clean these html leftovers with a regular expression: