1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
import pandas as pd import json
filename = ‘top5.txt‘ data = pd.read_csv(filename, sep=" ", header=None)
# test model.8.10 modelname 810 8101 2018-03-28 04:21:13 2018-03-28 04:21:13 # 1 0 2018-04-02 14:50:54 {"cell_info":"LTE PLMN:46000 EARFCN:38400(B39) Cell Identity # :197539969 PCI:141 TAC:37884 RSSI:-65 RSRP:-95 RSRQ:-11 SINR*10: 133 EMM state:REGISTERED # service state:NORMAL reg domain:CS_PS lte_tx_power tx = 9 lte_rx_chain0 rssi=-64 rsrp=-94 # sinr=133 lte_rx_chain1 rssi=-69 rsrp=-99 sinr=118 ","log_from":"com.android.phone", # "reg_at_time":"31112","rat":"14","reg_during_time":"3554","hplmn":"46002"} 2018-04-02
columns = [] for i in range(data.shape[1]): columns.append(‘A‘ + str(i)) data.columns = columns print(data.columns) # Index([‘A0‘, ‘A1‘, ‘A2‘, ‘A3‘, ‘A4‘, ‘A5‘, ‘A6‘, ‘A7‘, ‘A8‘, ‘A9‘, ‘A10‘,‘A11‘], # dtype=‘object‘)
print(data[‘A10‘]) # 0 {"cell_info":"LTE PLMN:46000 EARFCN:38400(B39... data = data.join(data[‘A10‘].apply(json.loads).apply(pd.Series))
print(data.columns) # Index([‘A0‘, ‘A1‘, ‘A2‘, ‘A3‘, ‘A4‘, ‘A5‘, ‘A6‘, ‘A7‘, ‘A8‘, ‘A9‘, ‘A10‘, # ‘A11‘, ‘cell_info‘, ‘hplmn‘, ‘log_from‘, ‘rat‘, ‘reg_at_time‘, # ‘reg_during_time‘], # dtype=‘object‘)
|