I want to create a binary column which indicates 1 if the values of both columns in the following table are within the same range. For example, if the value on cat_1 is between 5-10 and the value in cat_2 is also between 5-10 then it should indicate 1, otherwise, it should be 0. So far, I have tried the
Appending Dataframe in for loop is not working
I’m getting crazy with that. I don’t know why is not working well. My loop is the following: In the first print I obtain: But when I show the following dataframe value: I obtain: So it seems that is only concatenating the last value. PD: See charge column in order to see differences between datafr…
Dividing 24h into working shifts in Python Pandas
I am dealing with dividing a day into working shifts. Let’s have a look at my sample code: I’d like to divide the time into 3 shifts, 00:00 to 08:00 is Shift1, 08:00 to 16:00 will be Shift2 and till 00:00 will be Shift3. What I get is true, but I would like to know if there is any elegant
Remove duplicates from each cell
I have a file like this and need to remove duplicates in each cell without changing the order or format The missing data are noted as . (dot). So far I have tried with awk But it is killing the format. Is there any other way to do this ? Expected output Answer with sed
Identify and count segments between a start and an end marker
The goal is to fill values only between two values (start and end) with unique numbers (will be used in a groupby later on), notice how the values between end and start are still None in the desired output: Code: Answer Usually problems like these are solved by fiddling with cumsum and shift. The main idea fo…
Length of the intersections between a list an list of list
Note : almost duplicate of Numpy vectorization: Find intersection between list and list of lists Differences : I am focused on efficiently when the lists are large I’m searching for the largest intersections. Here are some assumptions: y is a list of ~500,000 sublist of ~500 elements each sublist in y i…
How to get a url from a html code with re.finall in python
This is my html – I want to get url of Link1 with python as a variable – Answer Actaually i found this using github copilot –
Make dictionary from multiple list
I have a list of customers, and I want to generate a list of random numbers between 1 to 4 for each customer. I used the code below: but I want to have a dictionary like: How would I go about doing this in python? Answer Slight modifications to your existing loop is all you need. You can use your
How to I adjust this nested loop to store the output of different URL requests in separate databases or .csv files?
so I’m working at a simple project but apparently I’m stuck at the first step. Basically I’m requesting the .json files from a public github repository. 7 different files which I aim to download and convert to 7 differently named databases. I tried to use this nested loop, trying to create 7…
upload multiple files with fetch
I am trying to receive more than one file per time using reactjs and flask api, but I get this error fontend code using reactjs backend code using flask flask receiving the files as [‘[object File],[object File]’] . I tried to find ways to read an object file but nothing worked can anyone help.. A…