i have string of values retrieved after filtering through data csv file. had filtering of data have same numbers list, dataframe, or array. need take numbers in string , convert them hex , take first 8 numbers of hex , convert dec each element in string. lastly need convert last 8 of same hex , dec each value in string.
i cannot provide snippet because sensitive data, here example.
i have this
>>> list_a [52894036, 78893201, 45790373] if convert dataframe , call df.dtypes, says dtype: object , can convert values of column bool, int, or string, dtype object.
it not matter whether function, or simple loop. have been trying many methods , unable attain results need. data taken different csv files , never same values or list size.
i'm not following question, ought cover of you're trying do. i'll in pandas since seem doing way, far question concerned standard python.
import pandas pd df=pd.dataframe({ 'a':[52894036999, 78893201999, 45790373999] }) df['b'] = df['a'].apply( hex ) df['c'] = df['b'].str[:10] df['d'] = df['c'].apply( lambda x: int(x,base=0) ) df b c d 0 52894036999 0xc50baf407l 0xc50baf40 3305877312 1 78893201999 0x125e66ba4fl 0x125e66ba 308176570 2 45790373999 0xaa951a86fl 0xaa951a86 2861898374 note pandas has 2 main dtypes: numbers (ints or floats) , objects. objects can anything, including strings.
df.dtypes int64 b object c object d int64 sometimes can more informative check type of individual elements of column, rather dtype of whole column. here we'll @ first row , can see middle 2 columns strings.
for col in df.columns: print( type(df[col].iloc[0]) ) <type 'numpy.int64'> <type 'str'> <type 'str'> <type 'numpy.int64'>
Comments
Post a Comment