读取文件
作者:互联网
1.读取.gpickle文件
di_graph = nx.read_gpickle("/home/sidz/GEM/data/hep_th/graph.gpickle")
2.读取emb文件
list_of_files = glob.glob("/home/jovyan/work/GEM/assets/0.4.2/sd_sample_real_re_social.emb")
latest_file = max(list_of_files, key=os.path.getctime)
tmp_data=pickle.load( open(latest_file, 'rb') )
df = pd.DataFrame(tmp_data, index=phone_md5_df['phone_md5'])
df.rename(columns=lambda x: 'emb'+str(x), inplace=True)
# emb0 emb1 emb2 emb159
# phone_md5
# fd96d73fc58f273247bcd2b475b00bad 2.792275e-07 -1.566772e-06 -4.783994e-07 6.518562e-05
# 3f740a57dded4635be99d825fef7e198 1.030452e-20 3.505315e-20 2.342541e-20 6.519042e-07
# fbd7cf02a3495064d7ce5242a1b158ad 2.711913e-03 -1.375571e-03 1.828684e-04 3.799617e-06
# 6291c10b854b15b58c41d1c2a8181943 4.497268e-20 1.400985e-19 9.673027e-20 6.212105e-05
# cec5ab7d24391b4df3b6a1e0d25269ee 3.656161e-20 1.043665e-19 7.137551e-20 6.212171e-05
3.读取mat文件
import scipy.io
mat = scipy.io.loadmat('./Homo_sapiens.mat') --稀疏矩阵 <class 'dict'>
标签:文件,20,读取,emb,df,gpickle,07 来源: https://www.cnblogs.com/hapyygril/p/11193037.html