Skip to content
Advertisement

Tag: dataframe

Pandas finding local max and min

I have a pandas data frame with two columns one is temperature the other is time. I would like to make third and fourth columns called min and max. Each of these columns would be filled with nan’s except where there is a local min or max, then it would have the value of that extrema. Here is a sample

Pandas sort_values does not sort numbers correctly

I’m new to pandas and working with tabular data in a programming environment. I have sorted a dataframe by a specific column but the answer that panda spits out is not exactly correct. Here is the code I have used: The result that the sort method yields values in column ‘overall league position’ are not sorted in ascending or order

Sequentially counting repeated entries

I am currently working on a project where I have to measure someones activity over time on a site, based on whether they edit a site. I have a data frame that looks similar to this: I want to add a column to the dataframe such that it counts the number of repeated values (number of edits, which is column

How to reverse a dummy variables from a pandas dataframe

I would like to reverse a dataframe with dummy variables. For example, from df_input: To df_output I have been looking at the solution provided at Reconstruct a categorical variable from dummies in pandas but it did not work. Please, Any help would be much appreciated. Many Thanks, Best Regards, Carlo Answer We can use wide_to_long, then select rows that are

Apply log2 transformation to a pandas DataFrame

I want to apply log2 with applymap and np2.log2to a data and show it using boxplot, here is the code I have written: and below is the boxplot I get for my RAW data which is okay, but I do get the same boxplot after applying log2 transformation !!! can anyone please tell me what I am doing wrong and

Grouping by multiple columns to find duplicate rows pandas

I have a df I want to group by val1 and val2 and get similar dataframe only with rows which has multiple occurance of same val1 and val2 combination. Final df: Answer You need duplicated with parameter subset for specify columns for check with keep=False for all duplicates for mask and filter by boolean indexing: Detail:

Advertisement