grouping

Pandas data frame with time-series data – grouping without aggregating data

Pandas data frame with time-series data – grouping without aggregating data Question: I have the following pandas dataframe: import pandas as pd df4 = pd.DataFrame({‘timestamp’:[‘2022-10-01 01:00:00’, ‘2022-10-02 01:00:00’, ‘2022-10-03 01:00:00’, ‘2022-10-04 01:00:00’, ‘2022-10-05 01:00:00’, ‘2022-10-01 02:00:00’, ‘2022-10-02 02:00:00’, ‘2022-10-03 02:00:00’, ‘2022-10-04 02:00:00’, ‘2022-10-05 02:00:00’], ‘A’: [1,2,3,4,5,6,7,8,9,10], ‘B’: [10,9,8,7,6,5,4,3,2,1]} ) df4[‘timestamp’] = df4[‘timestamp’].astype(‘datetime64’) df4 that gives …

Total answers: 1

Group numbers into bins based on offset with Python

Group numbers into bins based on offset with Python Question: I have a list like this: ls = [0, 1, 2, 4, 6, 7] # it won’t have duplicates and it is sorted Now I want to group this list into bins based on a offset (in this example offset=1) which should return this: [[0, …

Total answers: 1

Grouping list of dictionary by keys (in a nested dictionary)

Grouping list of dictionary by keys (in a nested dictionary) Question: I have a list of dictionaries like below (sample): {‘platform’: ‘amazonwebservicesaws’, ‘region’: ‘useastnorthernvirginia’, ‘data’: {‘on_demand_price’: {‘usd’: ‘40.00’}}} {‘platform’: ‘amazonwebservicesaws’, ‘region’: ‘useastnorthernvirginia’, ‘data’: {‘on_demand_price’: {‘eur’: ‘33.33’}}} {‘platform’: ‘amazonwebservicesaws’, ‘region’: ‘useastnorthernvirginia’, ‘data’: {‘capacity_storage_price’: {‘usd’: ‘23.00’}}} {‘platform’: ‘amazonwebservicesaws’, ‘region’: ‘useastnorthernvirginia’, ‘data’: {‘capacity_storage_price’: {‘eur’: ‘19.17’}}} {‘platform’: ‘amazonwebservicesaws’, ‘region’: …

Total answers: 1

Filtering DataFrame on groups where all elements of one group fullfills a one of various conditions

Filtering DataFrame on groups where all elements of one group fullfills a one of various conditions Question: I need to filter a data frame with different groups. The data frame looks as follows: df = pd.DataFrame({"group":[1,1,1, 2,2,2,2, 3,3,3, 4,4], "percentage":[70,70,70, 45,80,60,70, 71,85,90, np.nan, np.nan]}) My goal is to return a data frame containing only groups …

Total answers: 2

Can .apply use information from other groups?

Can .apply use information from other groups? Question: For each element in a group determine if it is present in the next group (in order as these groups appear – not necessarily numerical). For the last group – all False. Example: df = pd.DataFrame({‘group’: [ 0, 1, 1, 0, 2 ], ‘val’: [‘a’, ‘b’, ‘a’, …

Total answers: 1

Grouping pandas series based on condition

Grouping pandas series based on condition Question: I have a Pandas df with one column the following values. Data 0 A 1 A 2 B 3 A 4 A 5 A 6 B 7 A 8 A 9 B I want to try and group these values as such, for each encounter of Value B, …

Total answers: 3

How can I extract the bins from seaborn's KDE distplot object?

How can I extract the bins from seaborn's KDE distplot object? Question: Background I am trying to group ~11,000 genes of a species of plant (Arabidopsis thaliana), by data I have of their change in expression levels, in response to light exposure. The raw values, per gene, are continuous random variables, but I wish to …

Total answers: 2

Removing duplicate records from CSV file using Python Pandas

Removing duplicate records from CSV file using Python Pandas Question: I would like to remove duplicate records from a csv file using Python Pandas The CSV contains records with three attributes scale, minzoom, maxzoom. I want to have a resulting dataframe with minzoom and maxzoom and the records left being unique i.e Input CSV file …

Total answers: 4