问题描述
我有一个名为 ['EventorNot'] 的列的 Pandas DataFrame df,只有值“1.0”或“0.0”。我做了以下事情:
import pandas as df
import numpy as np
from patsy import dmatrices,dmatrix,demo_data
# first,I try to select all unique value of the column and turned it into a level list
levels = np.array(df['EventorNot'].astytpe(str).unique()).tolist()
# then,I try to turn the column into a categorical data with patsy:
dmatrix ("C(EventorNot,levels = levels),df.to_dict())
然后:我收到一条错误消息 将数据转换为分类时出错:值为 0 的观察值与任何预期水平都不匹配 我尝试了另一个具有相似值的列,但出现了相同的错误。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)