Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
1 answer
169 views

Get Dataframe from pandas groupby (pd.grouper)

From the below data, i need to create daywise chunk through iteration data: lable datetime value daytime 0 tag1 5/30/2022 0:00 361.378 2022-05-30 00:00:00 1 ...
arya's user avatar
  • 35
1 vote
2 answers
61 views

Give unique identifiers to clusters containing the same value

Say I had a dataframe column of ones and zeros, and I wanted to group by clusters of where the value is 1. Using groupby would ordinarily render 2 groups, a single group of zeros, and a single group ...
ajsp's user avatar
  • 2,670
0 votes
1 answer
848 views

How to count the values of multiple '0' and '1' columns and group by another binary column ('Male' and Female')?

I'd like to group the binary information by 'Gender' and count the values of the other/ following fields 'Married', 'Citizen' and 'License' The below code was my attempt, but it was unsucessful. ...
Johnnyduke's user avatar
0 votes
1 answer
314 views

python pandas. Sum of a column based on a match of string column in a comma separated values of another column

I have 2 data frames sample, with names changed: df1 = Comp_code DepartmentListA DepartmentListB Code_1 "Dept1" "Dept3" Code_2 "Dept2" "Dept4" Code_3 "...
D3110's user avatar
  • 17
1 vote
2 answers
58 views

Python pandas. Need to aggregate if column value is in another comma separated value column of second dataframe

I have 2 data frames sample, with names changed df1 = | Comp_code | DepartmentListA | DepartmentListB | | -------- | --------------- | --------------- | | Code_1 | "Dept1" | &...
D3110's user avatar
  • 17
0 votes
1 answer
77 views

pandas how to split one row to multiple row for variable product?

I have multiple variable product in my csv. Assume I have an product which title "Car model145" and this "Car model145" have three different price and size. Now I want to expand ...
boyenec's user avatar
  • 1,637
1 vote
2 answers
90 views

Conditional groupping in Python using groupby function on Dataframe

I was coding for a project and I got stuck here. I have used groupby function before but not like this. My doubt is- I have a dataframe as belows: | ID | Side | Price | | 1 | left | 100 | | 2 | ...
Sarthak Agrawal's user avatar
0 votes
1 answer
211 views

Split daily data into Weekly data

I am using the nsepy module to get the data for 2 week for SBIN share. Code : from nsepy import get_history from datetime import date import pandas as pd today = date.today() # print(today) sbin = ...
girish's user avatar
  • 33
0 votes
1 answer
99 views

Filter maximum value and corresponding date based on the country time series data using group by?

I'm trying to find which day has the maximum number of new cases and group-by country. The dataset contains the list of country time-series data with the number of COVID total cases, new cases, new ...
Kum_R's user avatar
  • 378
0 votes
1 answer
1k views

Split a Dataframe per time interval

I have a dataframe in the following format: timestamp,name,age 2020-03-01 00:00:01,nick 2020-03-01 00:00:01,john 2020-03-01 00:00:02,nick 2020-03-01 00:00:02,john 2020-03-01 00:00:04,peter 2020-03-01 ...
e7lT2P's user avatar
  • 1,961
3 votes
2 answers
953 views

Pandas groubpy on substring or regex

Given a pandas dataframe. How can i do a groupby on the column 'a' such all rows get grouped together that start with the same string. The end of the comparison part is the _. (So here y_s1 and y_s2 ...
user3680510's user avatar
0 votes
1 answer
62 views

How to apply a function fastly on the list of DataFrame in Python?

I have a list of DataFrames with equal length of columns and rows but different values, such as data = [df1, df2,df3.... dfn] . How can I apply a function function on each dataframe in the list ...
Sam's user avatar
  • 45
3 votes
2 answers
60 views

Mutliple sums on the same dataframe

I'm trying to perform multiple sums on the same dataframe and then concatenate the new dataframes into one final dataframe. Is there a concise way of doing this, or do I need use iteration ? I have a ...
Paulloed's user avatar
  • 373
1 vote
1 answer
135 views

Add missing datetime rows and check duplicates

I'm relatively new to pandas and I hope you could give me a hand ;-) I want to group a pandas dataframe by name_id and datetime, adding also missing datetime values (NaN). Input example: name_id ...
Agus's user avatar
  • 13

15 30 50 per page
1
2 3 4 5
9