Skip to content

Tag: pandas

Find median of interval data in python

I am exploring different python libraries and I wondering how to find approximate median value of the grouped data set. Here is a table for a reference. Age frequency 1-10 123 10-20 350 20-30 200 30-40 1700 40-50 360 50-60 60 Is there any function or do I need to hard code the formula and then have a loop goi…

Apply a softmax function on groupby in the same pandas dataframe

I have been looking to apply the following softmax function from https://machinelearningmastery.com/softmax-activation-function-with-python/ I am trying to apply this to a dataframe which is split by groups, and return the probabilites row by row for a group. My dataframe is: In this instance there are two di…

add a suffix when col names are similar

I am merging two dataframes and both of them have a col called “man”. After the join, one col is called “man_x” and the second is called “man_y”. Is it possible to append the table name or any other string instead of x, y when column names are the same? After this, If I add…

Multiple boxplots based on conditions

I have a dataframe with two columns. The power column represents the power consumption of the system. And the component_status column divide the data in two, based when the component is OFF or ON. When the values are 153 is when the component is ON and when the values are 150 the component is OFF. The result …

Panda iterating through CSV matching index out-of-bounds

I’m running into an issue with my locate / match statement. I’m trying to match the column “IP” assign it as the index and iterate through a csv of a few thousand hosts. Whenever the below script makes its way back up to process the second ‘IP’ I fail with a “single p…

Python Data Frame summary

I have dataframe (df table below): Every user can post in any category. I have to calculate HOW MANY DISTINCT USERS has a post in category A and at the same time has posts in categories, B, C and D. Table like: User Category 1 A 1 B 33 B 33 C 33 D 54 A 54 B 87 A