sorting

Filter data frame based on absolute difference

Filter data frame based on absolute difference Question: I have the following data frame: import pandas as pd d1 = {‘id’: ["car", "car", "car", "plane", "plane", "car"], ‘value’: [1, 1.2, 5, 6, 1.3, 0.8]} df1 = pd.DataFrame(data=d1) df1 id value 0 car 1.0 1 car 1.2 2 car 5.0 3 plane 6.0 4 plane 1.3 …

Total answers: 3

Removing rows based on the combined value of other rows

Removing rows based on the combined value of other rows Question: I want to remove the row with "SubAggregate"=’All’ if the rows with the same "Month" and "MainAggregate" sums ("ValueTraded") to the same as the corresponding "SubAggregate"=’All’ value My idea was to group by "MainAggregate" and "Month" and if the value was equal to two …

Total answers: 1

How can I sort my dates in a numpy array in order?

How can I sort my dates in a numpy array in order? Question: I have this numpy array called all_periods: array([’01/01/2021′, ’01/01/2022′, ’02/01/2021′, ’02/01/2022′, ’03/01/2020′, ’03/01/2021′, ’03/01/2022′, ’04/01/2020′, ’04/01/2021′, ’04/01/2022′, ’05/01/2020′, ’05/01/2021′, ’06/01/2020′, ’06/01/2021′, ’07/01/2020′, ’07/01/2021′, ’08/01/2020′, ’08/01/2021′, ’09/01/2020′, ’09/01/2021′, ’10/01/2020′, ’10/01/2021′, ’11/01/2020′, ’11/01/2021′, ’12/01/2020′, ’12/01/2021′], dtype=object) I want to sort this by day, month …

Total answers: 4

Sorting a Dataframe by column containing char-digit-char values

Sorting a Dataframe by column containing char-digit-char values Question: I have a column in my Dataframe that has values that look like this (I want to sort my Dataframe by this column): Mutations=[‘A67D’,’C447E’,’C447F’,’C447G’,’C447H’,’C447I’,’C447K’,’C447L’,’C447M’,’C447N’,’C447P’,’C447Q’,’C447R’,’C447S’,’C447T’,’C447V’,’C447W’,’C447Y’,’C447_’,’C92A’,’C92D’,’C92E’,’C92F’,’C92G’,’C92H’,’C92I’,’C92K’,’C92L’,’C92M’,’C92N’,’C92P’,’C92Q’,’C92R’,’C92S’,’C92T’,’C92V’,’C92W’,’C92_’,’D103A’,’D103C’,’D103F’,’D103G’,’D103H’,’D103I’,’D103K’,’D103L’,’D103M’,’D103N’,’D103R’,’D103S’,’D103T’,’D103V’,’silent_C88G’,’silent_G556R’] Basically all the values are in the format of Char_1-Digit-Char_2 I want to sort them with Digit being the highest priority and …

Total answers: 1

Sorting by subsampling every nth element in numpy array?

Sorting by subsampling every nth element in numpy array? Question: I am trying to sample every nth element to sort an array. My current solution works, but it feels like there should be a solution that does not involve concatenation. My current implementation is as follows. arr = np.arange(10) print(arr) [0 1 2 3 4 …

Total answers: 2

Ordering data in python or excel

Ordering data in python or excel Question: I have a large csv file of unordered data. It consists of music tags. I am trying to group all of the similar tags together for easier analysis. An example of what I have: Band1, hiphop, pop, rap Band2, rock, rap, pop band3, hiphop, rap The output I …

Total answers: 3