I have a csv dataset (with > 8m rows) that I load into a dataframe. The csv has columns like: I am able to load the dataset into my dataframe, but then I need to add multiple calculated columns to the dataframe for each row. In otherwords, unlike this SO question, I do not want the rows of the new
Tag: python
SimPy, How to incorporate a break for resources?
At the moment I am creating doctors as following: These doctors are requested for a flow of patients using the following: What I would like to do, is initialize the doctors with some kind of fatigue level (and other characteristics) like: Then in the encounter I would like to access the doctor to add fatigue …
How to generate “n” rows of Entry boxes from another Entry box?
I want to get an integer from an entry field and create new entry boxes below that. I have written a code to do that using a button. However, I want to make it happen automatically without a button as I entered the number, the rows update. I saw one way to automate it is using the callback. So, I
Change ‘1 Apr 2022, noon’ to datetime format python
I want to change ‘1 Apr 2022, noon’ to YYYY-MM-DD HH:MM:SS format. I know the datetime thing in python has the ability to parse but I am unsure how Answer You can use the dateparser module’s parse() function: This gets us a datetime.datetime object. We can now call strftime() to format it pr…
Accessing and overwriting Multiindex df data
I’m trying to multiply all the values of the following multiindex df for which the first multiindex equals Property_2 with a scalar: I’ve tried various ways: but I am getting back nan’s in the relevant places. Answer That’s because the indices don’t match. One way to get around t…
how to print everything from a dictionary?
I’m trying to do this question for class that is really confusing me, I can’t seem to figure it out. They give me this code and say that I need to do something to make it print all of the flowers in the dictionary instead of printing just one. Here is the code that is provided, which just prints o…
How to obtain dataframe from grouped element after using apply
Let’s say this the dataframe: Then the goal is to produce this: The total Val1 is Y as long as one of the instances is Y. My code looks like this: This works except that cumulative has dtype object and I can only access Val1, that is, I cannot access First Name or Last Name (Although when I run print(cu…
How to update key of dictionary inside a JSON file?
This is an example of what’s in my JSON file: How would I change the male’s key (which is 0) and add one using “+=” in python? I wan a command to update the key of male or female. I don’t want to CHANGE 0 into 1, but I want to “+=” to that 0 so that I can update
How to change whole app’s theme when used within Class, Tkinter, ttkThemes, ThemedTk Python
Summary: I searched the internet about additional themes for tkinter. I found ttkthemes – ThemedTk option. However, my app is created within class. The difference between the example shown in the module website, the themedtk example is applied with root method. Here is the code: When I run the applicati…
Reading multiple log files from a folder using python
In the past I have read a log file using python with the following code, which has always worked fine: For a particular use case that I am working on, I need to read multiple files contained in a folder. Can someone please suggest how to modify the above code (I tried that using blob but could not succeed)? T…