How to get coefficients from a model in R?

I am trying to store coefficients from a mle model just like a normally do for other models. Surprisingly, it throws an error. Any other methods to store it? set.seed(111) y.size <- rnorm(100,4,1) p <- rnorm(100,5,1) df <- data.frame(p, y.size) glae <- function(A,K,Ka,q, sigma, c) { lnqp <- if(q == 0) log(p) else ((p^q -… Read More How to get coefficients from a model in R?

how to specify data on pearson correlation heatmap?

I have a pearson correlation heat map coded, but its showing data from my dataframe which i dont need. is there a way to specify which columns i’d like to include? thanks in advance sb.heatmap(df[‘POPDEN’, ‘RoadsArea’, ‘MedianIncome’, ‘MedianPrice’, ‘PropertyCount’, ‘AvPTAI2015’, ‘PTAL’].corr(), annot=True, fmt=’.2f’) ————————————————————————— TypeError Traceback (most recent call last) <ipython-input-54-832fc3c86e3e> in <module> —-> 1… Read More how to specify data on pearson correlation heatmap?

Dataframe conditional replacement with intigers

I have a dataframe column like this: df[‘col_name’].unique() >>>array([-1, ‘Not Passed, On the boundary’, 1, ‘Passed, On the boundary’, ‘Passed, Unclear result’, ‘Passes, Unclear result, On the boudnary’, ‘Rejected, Unclear result’], dtype=object) In this column, if an element contains the word ‘Passed’ as a field or as a substring, then replace the entire field with… Read More Dataframe conditional replacement with intigers

R: Calculate percentage of observations in a column that are below a certain value for panel data

I have panel data and I would like to get the percentage of observations in a column (Size) that are below 1 million. My data is the following: structure(list(Product = c("A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "C", "C", "C", "C", "C", "C"), Date = c("02.05.2018", "04.05.2018", "05.05.2018", "06.05.2018", "07.05.2018",… Read More R: Calculate percentage of observations in a column that are below a certain value for panel data

Export Postgresql Table to excel with header in Python

My code works but it doesn’t bring the header with the names, it only brings the numbers 0 1 … 10 , what can I do ? Utils_db.py def consulta_sql(sql): try: connection = psycopg2.connect(user="postgres", password="postgres", host="localhost", port="5432", database="tb_cliente") cursor = connection.cursor() except (Exception, psycopg2.Error) as error: try: cursor.execute(sql) connection.commit() except (Exception, psycopg2.Error) as error: finally:… Read More Export Postgresql Table to excel with header in Python

Check for duplicate rows for a subset of columns in a Pandas DataFrameGroupBy object

Suppose I have a groupby object (grouped on Col1) like below: Col1 Col2 Col3 Col4 Col5 —————————————- AAA 001 456 846 239 row1 002 374 238 904 row2 003 456 846 239 row3 BBB 001 923 222 398 row1 002 923 222 398 row2 003 755 656 949 row3 CCC 001 324 454 565 row1… Read More Check for duplicate rows for a subset of columns in a Pandas DataFrameGroupBy object