There could be a mistake in @JARH's answer in the case of a multivariable regression. (I do not have enough reputation to comment.)
In the following line:
p_values =[2*(1-stats.t.cdf(np.abs(i),(len(newX)-1))) for i in ts_b]
,
the t-values follows a chi-squared distribution of degree len(newX)-1
instead of following a chi-squared distribution of degree len(newX)-len(newX.columns)-1
.
So this should be:
p_values =[2*(1-stats.t.cdf(np.abs(i),(len(newX)-len(newX.columns)-1))) for i in ts_b]
(See t-values for OLS regression for more details)