Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • f115cd0
  • /
  • global_methods.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:314b012c87c79fe557e05a304724a0d0f567067d
directory badge Iframe embedding
swh:1:dir:f115cd09f0791734573b74657def66c62323dff0

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
global_methods.py
import pandas as pd

import global_variables as gv
import numpy as np


def fill_nan_values(df):

    df = df.fillna(df.mean())
    df = df.fillna('not defined')  # still have to be defined for correctly identified column data types

    return df.iloc[:, 0]


def get_column_id(df, name):
    if name in list(df.columns):
        return name
    else:
        if '_' in name:
            return get_column_id(df, name.rsplit('_', 1)[0])
        else:
            return False


def normalize_values(current_col_for_normalization, current_data_type, col_id):
    current_col_normalized_in_function = current_col_for_normalization

    if current_data_type == gv.id_data_type__numerical or current_data_type == gv.id_data_type__date:
        # normalize_column(current_col)
        # mean_val = current_col.mean()
        # std_val = current_col.std()

        min_val = np.amin(current_col_for_normalization)
        max_val = np.amax(current_col_for_normalization)

        normalized_values = list()

        for index_normalization in range(len(current_col_for_normalization)):
            row = current_col_for_normalization[index_normalization]

            if np.isnan(min_val):
                normalized_values.append(row)
            elif min_val == max_val:
                normalized_values.append(row)
            else:
                normalized_values.append((row - min_val) / (max_val - min_val))

        current_col_normalized_in_function = pd.Series(normalized_values)
        current_col_normalized_in_function = current_col_normalized_in_function.rename(col_id)

    return current_col_normalized_in_function

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API