2017-02-24 26 views
2

當我運行下面的代碼:如何處理Python中的系統錯誤?

import pandas as pd 

web_states = {'Day':[1,2,3,4,5,6],  
       'Visitors': [43,53,46,78,88,24], 
       'BounceRates':[65,74,99,98,45,56]} 

df= pd.DataFrame(web_states) 

print(df) 

我得到以下錯誤:

File "C:\Users\Python36-32\lib\site-packages\numpy\core_init_.py"‌​, line 16, in from . import multiarray SystemError: initialization of multiarray raised unreported exception

請指教。

+0

運行上面的代碼後,我有下面的錯誤, 回溯(最近通話最後一個): 文件「C:/用戶/卡爾蒂克/桌面/甘吉/蟒蛇/日。 py「,第1行,在 import pandas as pd SystemError:初始化多陣列引發的未報告異常 –

+1

什麼是錯誤? – user3378165

+1

'pritn' - >'print'並組織你的問題,然後在問題中添加你的評論。 –

回答

0

跳出率太短。

您的代碼:

web_states = {'Day': [1, 2, 3, 4, 5, 6], 
       'Visitors': [43, 53, 46, 78, 88, 24], 
       'BounceRates': [65, 74, 99, 98, 45]} 
df = pd.DataFrame(web_states) 

產地:

File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 5446, in extract_index 
    raise ValueError('arrays must all be same length') 
ValueError: arrays must all be same length 

加長BounceRates:

web_states = {'Day': [1, 2, 3, 4, 5, 6], 
       'Visitors': [43, 53, 46, 78, 88, 24], 
       'BounceRates': [65, 74, 99, 98, 45, 0]} 
df = pd.DataFrame(web_states) 
print(df) 

產地:

BounceRates Day Visitors 
0   65 1  43 
1   74 2  53 
2   99 3  46 
3   98 4  78 
4   45 5  88 
5   0 6  24