added reverse list process

This commit is contained in:
mxr612 2024-05-15 20:20:32 +08:00
parent 3843df04cc
commit 594ebf9409
2 changed files with 19 additions and 2 deletions

View File

@ -161,7 +161,8 @@
"P6": "I can't stand being contradicted", "P6": "I can't stand being contradicted",
"P7": "I judge people by their appearance", "P7": "I judge people by their appearance",
"P8": "I am not easily annoyed", "P8": "I am not easily annoyed",
"P9": "I try to forgive and forget" "P9": "I try to forgive and forget",
"P10":"I have a good word for everyone."
}, },
"reverse":[ "reverse":[
"A8","A9","A10", "A8","A9","A10",
@ -179,6 +180,6 @@
"M6","M7","M8","M9","M10", "M6","M7","M8","M9","M10",
"N8","N9","N10", "N8","N9","N10",
"O6","O7","O8","O9","O10", "O6","O7","O8","O9","O10",
"P8","P9" "P8","P9","P10"
] ]
} }

View File

@ -24,6 +24,16 @@ def batch():
# print(items) # print(items)
return items return items
def reverse_list():
scales = os.listdir("Scales")
items=[]
for i in scales:
with open("Scales/"+i,"r") as scale:
tmp = json.load(scale)
items.extend(tmp["reverse"])
# print(items)
return items
def old_type(str): def old_type(str):
with open(str,"r") as file: with open(str,"r") as file:
scale=json.load(file) scale=json.load(file)
@ -78,12 +88,18 @@ def make_data():
def corelation(): def corelation():
data = pandas.read_csv("Work/data.csv") data = pandas.read_csv("Work/data.csv")
rev=reverse_list()
print(rev)
que={} que={}
for i in data: for i in data:
for j in data: for j in data:
if i!=j: if i!=j:
try: try:
que[i,j]=data[i].corr(data[j]) que[i,j]=data[i].corr(data[j])
if i in rev:
que[i,j]*=-1
if j in rev:
que[i,j]*=-1
que[j,i]=que[i,j] que[j,i]=que[i,j]
except: except:
pass pass