How to get range of values in secondary index of pandas dataframe

Advertisements I have a multi-indexed pandas dataframe with two indices. The first index is ‘room’, the second is ‘timestamp’. The columns of this table are ‘total occupancy’, ‘temperature’, ‘power used’ and ‘event’. The situation being tracked is consider a hotel with several ball rooms. these rooms get booked for events. Periodically, hotel mngmt records the… Read More How to get range of values in secondary index of pandas dataframe

Group by an overlapping category (a category should be grouped in 2 different other categories)

Advertisements I have a dataset where there are groups ‘gr1’, ‘gr2’, and ‘both’. Basically, I’d like to group the ‘gr’ column by c("gr1", "both") and c("gr2", "both"). Here I’m proposing a solution with a simple data frame, but I’d like to know if there is a way to make ‘complex’ grouping such as group_by(gr ”using… Read More Group by an overlapping category (a category should be grouped in 2 different other categories)

Python groupby function not recognising that there are keys that are identical that can be "grouped on"

Advertisements I have a list which I am trying to group by the first element of the nested list. The problem is that my code is not recognising that there are only 5 different values among the grouped on element. a = [[‘2.25.151989603747108360484758994222924880510’, 1], [‘2.25.23907329898781253437777953862543062317’, 1], [‘2.25.151989603747108360484758994222924880510’, 2], [‘2.25.23907329898781253437777953862543062317’, 1], [‘2.25.159215431212584126451402597802236328925’, 1], [‘2.25.339018106044083012102817776589396922392’, 1], [‘2.25.159215431212584126451402597802236328925’,… Read More Python groupby function not recognising that there are keys that are identical that can be "grouped on"

Group values and check if the values ​from another column cancel each other out in python pandas dataframe

Advertisements I need to check if the value inside "CP" columns of a dataframe, while my dataframe is grouped by "Centre" column, are canceling each others. Here is an example : Sample : Centre CP 3N7D 10 3N1F 2 3N90 -9 3N7D -1 3N7D -10 8D92 198 3N7D -10 3N90 2 8D92 -195 8D92 -3… Read More Group values and check if the values ​from another column cancel each other out in python pandas dataframe