Skip to content

Instantly share code, notes, and snippets.

@aidiss
Last active December 19, 2016 08:43
Show Gist options
  • Save aidiss/964a0a054c002cfd4fc4726b96a3c3d7 to your computer and use it in GitHub Desktop.
Save aidiss/964a0a054c002cfd4fc4726b96a3c3d7 to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
def eliminate_nuokrypiai(group, stds, zymejimas):
group[np.abs(group - group.mean()) > stds * group.std()] = zymejimas
return group
def palikti_nuokrypius(group, stds, zymejimas):
group[np.abs(group - group.mean()) <= stds * group.std()] = zymejimas
return group
# Pagal dėstytojo vertinimus studijų modulyje
index = ['Dėst', 'Studijų modulio kodas', 'Studijų modulio pavadinimas']
l = []
for klausimo_kodas in uzdaru_kodai_dest:
data = dfdest.set_index(index)
grouped = data.groupby(data.index)
filtered = grouped[klausimo_kodas]
transformed = filtered.transform(lambda x: eliminate_nuokrypiai(x, 2, np.nan))
l.append(transformed)
pagal_destytojo_vertinimus_modulyje = pd.concat(l, axis=1)
# Pagal modulių vertinimus
index = ['Studijų modulio kodas', 'Studijų modulio pavadinimas',]
l = []
for klausimo_kodas in uzdaru_kodai_mod:
data = dfmod.set_index(index)
grouped = data.groupby(data.index)
filtered = grouped[klausimo_kodas]
transformed = filtered.transform(lambda x: eliminate_nuokrypiai(x, 2, np.nan))
l.append(transformed)
pagal_moduliu_vertinimus = pd.concat(l, axis=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment