Commit d0a94da9 authored by Мария Григорьева's avatar Мария Григорьева
Browse files

Replace affiliations.py

parent 48dbfbb4
...@@ -121,8 +121,6 @@ def get_matrix(joint): ...@@ -121,8 +121,6 @@ def get_matrix(joint):
:return: :return:
""" """
unique = get_unique(joint) unique = get_unique(joint)
print(unique)
print(len(unique))
column_names, row_names = unique, unique column_names, row_names = unique, unique
matrix = np.zeros((len(unique), len(unique))) matrix = np.zeros((len(unique), len(unique)))
...@@ -150,8 +148,9 @@ def get_connections_df(matrix_df): ...@@ -150,8 +148,9 @@ def get_connections_df(matrix_df):
:param matrix_df: :param matrix_df:
:return: :return:
""" """
# takes the upper triangular matrix with the main diagonal
df = matrix_df.stack().sort_values(ascending=False).reset_index() df = matrix_df.where(pd.np.triu(pd.np.ones(matrix_df.shape), k=0)
.astype(bool)).stack().sort_values(ascending=False).reset_index()
df['level_0'] = df['level_0'].astype(np.int64) df['level_0'] = df['level_0'].astype(np.int64)
df['level_1'] = df['level_1'].astype(np.int64) df['level_1'] = df['level_1'].astype(np.int64)
df.rename(columns={0: "count"}, inplace=True) df.rename(columns={0: "count"}, inplace=True)
...@@ -180,7 +179,6 @@ def main(): ...@@ -180,7 +179,6 @@ def main():
query = _match_all_date_limit(START_DATE, END_DATE) query = _match_all_date_limit(START_DATE, END_DATE)
joint = get_joint_affiliations(es, INDEX_NAME, query) joint = get_joint_affiliations(es, INDEX_NAME, query)
print(joint)
matrix = get_matrix(joint) matrix = get_matrix(joint)
update_matrix(matrix, joint) update_matrix(matrix, joint)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment