'Attempting to create list from MNLogit results getting ValueError: Data must be 1-dimensional
I'm attempting to create a pandas dataframe from results from MNLogit (StatsModel). When I run each of the params separately, the lists print as expected, but when inserted in the data argument of DataFrame I get the ValueError: Data must be 1-dimensional. Not sure what the issue is here.
coefs = pd.DataFrame({
'coefficients': round(logit_res.params,4),
'odds ratio':round(np.exp(logit_res.params),4),
'p-value': round(logit_res.pvalues,4),
'col_name':logit_res.params.index}).sort_values(by='p-value', ascending=False)
These are the results when run individually
round(logit_res.params,4)
0
const -29.0178
0 -0.0000
1 0.0001
2 0.0176
3 0.0422
4 0.0865
round(np.exp(logit_res.params),4)
0
const 0.0000
0 1.0000
1 1.0001
2 1.0177
3 1.0431
4 1.0904
round(logit_res.pvalues,4)
0
const 0.0000
0 0.0001
1 0.0000
2 0.0000
3 0.0000
4 0.1303
logit_res.params.index
Index(['const', 0, 1, 2, 3, 4])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
