0

我有一个 pandas DataFrame df,其中有一列名为 ['EventorNot'],只有值“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 的观察与任何预期水平不匹配我尝试了具有相似值的另一列并且有相同的错误。

4

0 回答 0