Using Python how can you use a group-by to filter this dataset Start How can I make it so that where either the two conditions are accepted, filtering everything else that doesn’t meet these two criteria ID1 – Matches another ID1 and the Last3 are the same ID2 – Matches another ID2 and the F…
Tag: python
Check same value in multiple lists [python]
I’ve 5 lists with some Infos saved in like: What i’d like do is check them and create a table like that’s: I’ve no worries to import a new library like pandas or others. I tried to use some nested For loop to check if there’s double values in each list and if was true, add it, bu…
Pandas groupby filter only last two rows
I am working on pandas manipulation and want to select only the last two rows for each column “B”. How to do without reset_index and filter (do inside groupby) My attempt Required output Answer Try: Output:
How would I define a function for this? [Noob question]
I´m working on creating a list for a game I play with my friends where words get added x times to that list. Currently, I´m using the same three lines of code 5 times and I´d like to instead just call up a predefined funtion 5 times. is that possible? (I only translated the first line) Any help or pointing
Python add missing element into list
I have a list with day of a month as key and i want to add all missing day with 0 as value. This is a sample : And I looking for something like this : What is the better way to did it. This is my code : Answer You could simply make a run with numbers varying from
Optimal way to use multiprocessing for many files
So I have a large list of files that need to be processed into CSVs. Each file itself is quite large, and each line is a string. Each line of the files could represent one of three types of data, each of which is processed a bit differently. My current solution looks like the following: I iterate through the …
Plotly graph is displaying as empty
I have a dataframe with the columns where data about number of users per certain cars in several weeks is shown. I made a pivot table and i’m trying to build a plot with the pivot table in plotly I get no errors but the graph shows no lines. The x-axis and the line names are correct but the values
Matplotlib axline is vertical when it should be at an angle…until I change the dates/times for the chart
I’m trying to draw an angled line on a chart with Matplotlib, but there are times when it just draws a vertical line, incorrectly. It appears to be a problem with the dates/times. It’s like there’s a minimum time required between points before it will plot correctly. Can anyone shed any ligh…
Loading an object across multiple files
I’m making a game in Python, and I have an object to store all of the user’s preferences in, referred to as gameSettings. When running functions in a seperate file (functions.py) I have to create a new local gameSettings var in every single function in the file. This also means I have to run the g…
PySpark – Selecting all rows within each group
I have a dataframe similar to below. From the above dataframe, I would like to keep all rows upto the most recent sale relative to the date. So essentially, I will only have unique date for each row. In the case of above example, output would look like: Can you please guide on how can I go to this result?