<jupyter_start><jupyter_text>Time analysis<jupyter_code>%run "../Functions/4. User comparison.ipynb"
minimum152Date = min(min(rmdf152['userTime']), min(gform['Timestamp'])).date()
maximum152Date = max(max(rmdf152['userTime']), max(gform['Timestamp'])).date()
minimum152Date, maximum152Date
def plotPerDay(valuesPerDay, title='', loc=2, startDate=None, endDate=None):

    dateIndex = valuesPerDay.index

    if (startDate == None):
        startDate = min(dateIndex)
    if (endDate == None):
        endDate = max(dateIndex)

    dateIndex = pd.date_range(startDate, endDate)
    valuesPerDay = valuesPerDay.reindex(dateIndex, fill_value=0)

    ax1 = valuesPerDay.sort_index().plot(
        rot=90,
        label='per day',
        legend=False,
        color='blue',
    )
    ax1.set_ylabel("per day")
    h1, l1 = ax1.get_legend_handles_labels()

    ax2 = np.cumsum(valuesPerDay.sort_index()).plot(
        rot=90,
        label='cumulative',
        legend=False,
        secondary_y=True,
        color='red'
    )
    ax2.set_ylabel("cumulative")
    h2, l2 = ax2.get_legend_handles_labels()

    plt.legend(h1+h2, l1+l2, loc=loc)
    plt.title(title)
    plt.show()
def plotPerDay2(valuesPerDay, title='', loc=0, startDate=None, endDate=None):

    dateIndex = valuesPerDay.index

    if (startDate == None):
        startDate = min(dateIndex)
    if (endDate == None):
        endDate = max(dateIndex)

    dateIndex = pd.date_range(startDate, endDate)
    valuesPerDay = valuesPerDay.reindex(dateIndex, fill_value=0)
    
    fig = plt.figure()
    ax1 = fig.add_subplot(111)

    ax1.plot(valuesPerDay.sort_index().index, valuesPerDay.sort_index(), label='per day', color='blue')
    plt.xticks(rotation='vertical')
    ax2 = ax1.twinx()
    ax2.plot(valuesPerDay.sort_index().index, np.cumsum(valuesPerDay.sort_index()), label='cumulative', color='red')

    lines, labels = ax1.get_legend_handles_labels()
    lines2, labels2 = ax2.get_legend_handles_labels()
    ax2.legend(lines + lines2, labels + labels2, loc=loc)

    ax1.set_ylabel("per day")
    ax2.set_ylabel("cumulative")
    plt.title(title)
    plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14384828862164661, 'fraction_numerical': 0.0272895467160037, 'mean_word_length': 3.774834437086093, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '443329', 'license': 'CC0-1.0', 'n_tokens_mistral': 805, 'n_tokens_neox': 763, 'n_words': 121, 'path': 'v1.52/Functions/6. Time analysis.ipynb', 'repo_name': 'CyberCRI/herocoli-metrics-redwire', 'size': '2162'}