Python pandas insert long integer
Question: I'm trying to insert long integers in a Pandas Dataframe

    
    
    import numpy as np
    from pandas import DataFrame
    
    data_scores = [(6311132704823138710, 273), (2685045978526272070, 23), (8921811264899370420, 45), (17019687244989530680L, 270), (9930107427299601010L, 273)]
    dtype = [('uid', 'u8'), ('score', 'u8')]
    data = np.zeros((len(data_scores),),dtype=dtype)
    data[:] = data_scores
    df_crawls = DataFrame(data)
    print df_crawls.head()
    

But when I look in the dataframe, last values which are long are now negative
:

    
    
                           uid  score
    0  6311132704823138710    273
    1  2685045978526272070     23
    2  8921811264899370420     45
    3 -1427056828720020936    270
    4 -8516636646409950606    273
    

uids are 64 bits unsigned int, so 'u8' should be the correct dtype ? Any ideas
?


Answer: Yes-- it's a present limitation of pandas-- we do plan to add support for
unsigned integer dtypes in the future. An error message would be much better:

<http://github.com/pydata/pandas/issues/2355>

For now you can make the column `dtype=object` as a workaround.

EDIT 2012-11-27

Detecting overflows now, though will become dtype=object for now until
DataFrame has better support for unsigned data types.

    
    
    In [3]: df_crawls
    Out[3]: 
                        uid  score
    0   6311132704823138710    273
    1   2685045978526272070     23
    2   8921811264899370420     45
    3  17019687244989530680    270
    4   9930107427299601010    273
    
    In [4]: df_crawls.dtypes
    Out[4]: 
    uid      object
    score     int64
    

