'Logit Based on Column Condition?
Is there a way to regress using logit in python based on a condition from a column? For example, we have columns A--F, with A being the dependent (0,1 value) and B being a segment column (let's say Cat, Dog, Mouse) rest being independent. I would like to regress only if column B says "Cat". Is this possible? I've tried many methods but all have failed!
model = random_data[random_data['B'] = 'Cat', smf.logit("A ~ C + D + E", data = random_data)]
model.summary()
Even tried:
smf.logit("A ~ C + D + E", data = random_data[random_data['B'] = 'Cat')`
EDIT: I solved it with:
smf.logit("A ~ C + D + E", data = random_data[random_data['B'] == "Cat"]).fit()
Hope this helps someone!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
