2021-04-20
閱讀量:
904
看一個(gè)數(shù)據(jù)框?qū)ο蟮膇nfo屬性的時(shí)候出現(xiàn)問題
為了方便大家檢索到,我把錯(cuò)誤提示的文字版也貼出來 ---------------------------------------------------------------------------TypeError Traceback (most recent call last)in----> 1 df.info()d:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in info(self, verbose, buf, max_cols, memory_usage, null_counts) 2495 if "object" in counts or self.index._is_memory_usage_qualified(): 2496 size_qualifier = "+"-> 2497 mem_usage = self.memory_usage(index=True, deep=deep).sum() 2498 lines.append(f"memory usage: {_sizeof_fmt(mem_usage, size_qualifier)}\n") 2499 fmt.buffer_put_lines(buf, lines)d:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in memory_usage(self, index, deep) 2588 ) 2589 if index:-> 2590 result = Series(self.index.memory_usage(deep=deep), index=["Index"]).append( 2591 result 2592 )d:\ProgramData\Anaconda3\lib\site-packages\pandas\core\series.py in __init__(self, data, index, dtype, name, copy, fastpath) 303 data = data.copy() 304 else:--> 305 data = sanitize_array(data, index, dtype, copy, raise_cast_failure=True) 306 307 data = SingleBlockManager(data, index, fastpath=True)d:\ProgramData\Anaconda3\lib\site-packages\pandas\core\construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure) 463 value = maybe_cast_to_datetime(value, dtype) 464 --> 465 subarr = construct_1d_arraylike_from_scalar(value, len(index), dtype) 466 467 else:d:\ProgramData\Anaconda3\lib\site-packages\pandas\core\dtypes\cast.py in construct_1d_arraylike_from_scalar(value, length, dtype) 1459 value = ensure_str(value) 1460 -> 1461 subarr = np.empty(length, dtype=dtype) 1462 subarr.fill(value) 1463 TypeError: Cannot interpret '' as a data type
把df.info()改為df.info就對(duì)了,結(jié)果如下






評(píng)論(0)


暫無數(shù)據(jù)
CDA考試動(dòng)態(tài)
CDA報(bào)考指南
推薦帖子
0條評(píng)論
0條評(píng)論
0條評(píng)論
0條評(píng)論