尝试将Int转换为Categorical

时间:2019-10-14 20:40:07

标签: pandas syntax integer categorical-data

我有一个变量(不良指标),这也是我的目标。当前是INT 64,我正尝试转换为分类,但遇到语法错误,但我不知道为什么。将DTI从Object转换为Float可行。 。

import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
project = pd.read_csv('c:/users/Brandon Thomas/Project.csv')

project.dtypes
90+ Perf                                       int64
Bankruptcy Code                              float64
Bad Indicator                                  int64
RR Downgrade                                  object
Beacon Range                                  object
Product Grouping                              object
Final Product Grouping                        object
dtype: object

project["DTI"] = pd.to_numeric(project.DTI, errors='coerce')
project['Bad Indicator']=pd.categorical(project.Bad Indicator)

File "<ipython-input-166-b6f5f0432024>", line 2
    project['Bad Indicator']=pd.categorical(project.Bad Indicator)
                                                            ^
SyntaxError: invalid syntax

0 个答案:

没有答案