파이썬3
PRIME 1.0 결과물을 파이썬으로 불러들이는 스크립트
TTSR
2024. 1. 5. 10:52
728x90
반응형
def reading_prime_version1(path):
import pandas as pd
'''
This function loads prediction result of PRIME(version1.0)
path : /path/to/the/prime/1.0/result.txt
'''
with open(path,'r') as f:
f1=f.readlines()
f.close()
# Removing unnecessary part
f1=[line.replace('\n','') for line in f1 if '#' not in line]
# tab-delimination
f1=[line.split('\t') for line in f1]
# DATAFRAME
df=pd.DataFrame(f1[1:],columns=f1[0])
# Change value into numeric values
numeric_col=[i for i in df.columns if 'Rank' in i or 'Score' in i]
for c in numeric_col:
df[c]=df[c].astype(float)
return df
728x90
반응형