Skip to content

Tag: pandas-groupby

conditional groupby and update column – python, pandas, groupby

i have a df which I want to add a column that shows the student who is place (1) from the group(‘subject’, ‘class’) and update the column after there is a new place (1). code: ╔═════════╦═════════╦═════════╦═══════╗ ║ subject ║ class ║ student ║ place ║ ╠═════════╬═════════╬═════════╬═…

Get Top N items per month in pandas

I have the following dataframe (which is a pretty reduced sample from my original one). I’m trying to get the top 2 ids for each year AND month. So, for example, the idea was to obtain the below df. My main problem here, is to get the Top n along with the dates, because the nlargest method applies to a

Plotting row based data

I have some data that looks something like this: What I would like to do is to plot the values of the header dates, but grouped by id and period. So essentially this would become 6 line plots, with the x-axis given as the dates. However, maybe I’m just tired, but this data set is weirdly put together im…