Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

score_to_dataframe.py 1021 B

123456789101112131415161718192021222324252627282930313233
  1. import argparse
  2. import pandas as pd
  3. import numpy as np
  4. import json
  5. from pathlib import Path
  6. if __name__ == '__main__':
  7. CLI = argparse.ArgumentParser()
  8. CLI.add_argument("--output", nargs='?', type=str)
  9. CLI.add_argument("--input", nargs='?', type=str)
  10. CLI.add_argument("--params", nargs='?', type=str, default='')
  11. args, unknown = CLI.parse_known_args()
  12. if len(args.params):
  13. params = dict([param.split('=') for param in args.params.split(',')])
  14. else:
  15. params = {}
  16. add_params = dict([(k.strip('-'),v) for k,v in zip(unknown[:-1:2],unknown[1::2])])
  17. params.update(add_params)
  18. ext = Path(args.input).suffix
  19. if ext == '.npy':
  20. input = np.load(args.input, allow_pickle=True).item()
  21. elif ext == '.json':
  22. input = json.load(open(args.input))
  23. else:
  24. raise ValueError(f"Can't handle file type {ext}")
  25. params['score'], params['pvalue'] = input['score'], input['pvalue']
  26. df = pd.Series(params).to_frame().T
  27. df.to_csv(args.output)