I am trying to transform following tuple tuple into a dict (and a reversed one of that): This is the code I use: And I receive the following error: TypeError: unhashable type: ‘list’ How should I do this? Thank you a lot! Answer you are right, lists cannot be used as keys in python dict because ke…
how to divide revenue between check_in_date and check_out_date, and turn those dates into single column named date
I have an example of my dataset like this : and I want to turn it into something like this : The check_out date is not included in the range; so the first period is 2 days (27 and 28) with 50 revenue each. Answer Another method to solve this is first get difference between the out and in dates
my code is working on its own but wont run/print in my project as a whole
Hello I’m new to python and jumped into trying to automate reading my work schedule for fun really and have run into a block… I’ve written some code and it just won’t print in my main project but when taken out to test independently it runs just fine. what am I doing wrong? the with st…
How to create grouped and stacked bars
I have a very huge dataset with a lot of subsidiaries serving three customer groups in various countries, something like this (in reality there are much more subsidiaries and dates): I’d like to make an analysis per subsidiary by producing a stacked bar chart. To do this, I started by defining the x-axi…
Replace with Python regex in pandas column
There are many values starting with ‘^f’ and ending with ‘^’ in a pandas column. And I need to replace them like below : Answer You don’t mention what you’ve tried already, nor what the rest of your DataFrame looks like but here is a minimal example: Output
Match everything except a complex regex pattern and replace it in Pandas
I have a complex regex pattern to match mixed dates for a csv column in pandas df. I would like to replace everything except the regex pattern match with “” . I have tried pretty much all the negation cases (^ ?! and others). But I keep replacing the regex match with “” (empty string).…
How to set a maximum limit for dragging in tkinter PanedWindow?
In the above code, I don’t want the frame1 to expand too much when dragged. How can I set a limit for this? Answer There are no straightforward ways to do this. You can achieve this either by setting minsize for frame2. Something like this: Another way is to return “break” when the sash posi…
AWS Glue python shell – Using multiple libraries
I was using AWS glue python shell. The program uses multiple python libraries which not natively available for AWS. Glue can take .egg or .whl files for external library reference. All we need to do is put these .egg or .whl file in some S3 location and point to it using it’s full path. I tried with one…
How do I display the top & bottom 5 row values along with custom row values in Matplotlib?
I have a dataframe that’s about 750 odd rows, which is obviously excessive for a traditional bar chart. What I would like to do is have it display the Top 5 entries, the specific criteria that I’m looking for, and the bottom 5 entries. The dataframe is something like this: What I want to be able t…
Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: “python”:
I keep getting this error in a Docker container when I execute docker run. Dockerfile Docker process Error docker logs docker inspect 59a03e87fe83 Answer your python binary resides in /usr/local/bin and with your mount you override it with whatever is in /tmp path on your host