ValueError Traceback (most recent call last)
Cell In[43], line 1
----> 1 da2 = pd.DataFrame({
2 'target': ['disease', 'health'],
3 'xb': ['男', '女'],
4 'education': ['高中以下','高中以上'],
5 'income': ['小于10万', '10万以上'],
6 'work': ['生产运输人员', '专业技术人员','农商人员','其他'],
7 'fpzd': ['正常','皮下脂肪型肥胖','内脏脂肪型肥胖'],
8 'bc': ['<5年', '5-10年','10-15年','>15年'],
9 'gxy': ['否','是'],'jyy': ['否','是'],
10 'jzs': ['否','是'],'jty': ['否','是'],
11 'jtfa': ['否', '降糖药+胰岛素','胰岛素','口服降糖药'],'xys': ['否', '偶尔吸烟','每天吸烟'],
12 'yjs': ['否', '偶尔饮酒','每天饮酒'],'shucai': ['少于200g', '200-300g','300-400g','400g以上'],
13 'shuiguo': ['少于200g', '200g以上'],'scsgl': ['少于500克', '500克以上'],
14 'fish': ['小于等于1次', '大于等于2次,总量小于200克','大于等于2次,总量大于200克'],
15 'dzp': ['小于100克', '100-250','250-400','400g以上'],'syl': ['小于4克', '4~6g','6~8g','8g以上'],
16 'yl': ['从不喝或很少喝', '每周1-2瓶','每周3瓶以上'],'jlhd': ['否','是'],'zdhd': ['否','是'],
17 'smqk': ['睡眠感觉良好','睡眠感觉不好'],'wushui': ['否','是'], 'smsj': ['小于7小时', '7-10小时','>10小时'],
18 'ydjc': ['正常','异常'], 'sjcd': ['正常','异常'], 'xgjc': ['正常','斑块形成','内膜毛糙']})
File D:\anaconda3\Lib\site-packages\pandas\core\frame.py:778, in DataFrame.__init__(self, data, index, columns, dtype, copy)
772 mgr = self._init_mgr(
773 data, axes={"index": index, "columns": columns}, dtype=dtype, copy=copy
774 )
776 elif isinstance(data, dict):
777 # GH#38939 de facto copy defaults to False only in non-dict cases
--> 778 mgr = dict_to_mgr(data, index, columns, dtype=dtype, copy=copy, typ=manager)
779 elif isinstance(data, ma.MaskedArray):
780 from numpy.ma import mrecords
File D:\anaconda3\Lib\site-packages\pandas\core\internals\construction.py:503, in dict_to_mgr(data, index, columns, dtype, typ, copy)
499 else:
500 # dtype check to exclude e.g. range objects, scalars
501 arrays = [x.copy() if hasattr(x, "dtype") else x for x in arrays]
--> 503 return arrays_to_mgr(arrays, columns, index, dtype=dtype, typ=typ, consolidate=copy)
File D:\anaconda3\Lib\site-packages\pandas\core\internals\construction.py:114, in arrays_to_mgr(arrays, columns, index, dtype, verify_integrity, typ, consolidate)
111 if verify_integrity:
112 # figure out the index, if necessary
113 if index is None:
--> 114 index = _extract_index(arrays)
115 else:
116 index = ensure_index(index)
File D:\anaconda3\Lib\site-packages\pandas\core\internals\construction.py:677, in _extract_index(data)
675 lengths = list(set(raw_lengths))
676 if len(lengths) > 1:
--> 677 raise ValueError("All arrays must be of the same length")
679 if have_dicts:
680 raise ValueError(
681 "Mixing dicts with non-Series may lead to ambiguous ordering."
682 )
ValueError: All arrays must be of the same length
最新发布