LoanStats_securev1_2018Q1.info(verbose=True)
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 107866 entries, 0 to 107865
Data columns (total 151 columns):
id object
member_id float64
loan_amnt float64
funded_amnt float64
funded_amnt_inv float64
term object
int_rate object
installment float64
grade object
sub_grade object
emp_title object
emp_length object
home_ownership object
...
settlement_status object
settlement_date object
settlement_amount float64
settlement_percentage float64
settlement_term float64
dtypes: float64(119), object(32)
memory usage: 124.3+ MB
如何获取对象类型列存储在l1 = [id,term ..]和float64类型存储在l2 = [member_id,loan_amnt ...] 感谢那些熟悉熊猫帮助的人
答案 0 :(得分:1)
您可以使用select_dtypes
df.select_dtypes('object').columns.tolist()
或使用dtypes
df.dtypes.reset_index().groupby(0)['index'].apply(list)