Skip to content

Tag: pandas

automatic mean of multiple columns in python

I have a dataset with multiple variables. I am trying to group these variables according to the end of the name of variable and calculate the mean of each group. Here is an example of my dataset: What I am trying to do is to group the variables that ends with the same number, e.g.: [AST_0-01, AST_1-01, AST_2-…

Is pandas.read_spss misreading datetime into unix?

I have a sav file with a datetime column in %m/%d/%Y string format. When I read it in with pd.read_spss(), which doesn’t seem to have any datetime-related arguments, it ends up in what looks like unix time, except that the time would be a few centuries from now with unique values including 13778726400, …

Missing value Imputation based on regression in pandas

i want to inpute the missing data based on multivariate imputation, in the below-attached data sets, column A has some missing values, and Column A and Column B have the correlation factor of 0.70. So I want to use a regression kind of realationship so that it will build the relation between Column A and Colu…

Sorting values after transpose of dataframe

My dataframe is: 0 1 2 3 a 1091 347 2164 b 208 284 27647 c 0 8126 22 After transposing 0 a b c 1 1.091 208 0 2 347 284 8126 3 2161 27647 22 But I am getting an error like: I am trying to plot index values to a column but it should be in ascending

How to perform addition of two dataframe columns based on condition

I have two dataframes with different sizes and I am trying to perform an addition of values from a common column found in both dataframes based on matching values in another common column. My first dataframe looks like this: df1 df2 looks like this My expected results is How would I go about this please? My f…