My raw data is as follows:
id_2 column_A
602 1
602 1
602 1
602 1
602 3
602 8
602 15
602
602
My dataframe:
df = pd.read_csv('xxyy.csv')
df = df.fillna(np.nan)
My requirement is: I have to find the less than count for each value for ex:(for 1 its 0, for 3 its 4,etc)
EDIT:
def func1(value):
return df['column_A'][df['column_A'] < value].count()
for name, df in df.groupby(['id_2']):
for j in df.index:
y = func1(df['column_A'].ix[j])
print y
what i am getting is:
for 3 its 5, for 8 its 6, for 15 its 4, what should i want is: for 3 it should be 6, for 8 it should be 7, for 15 it should be 8 (included 2 nan)
Aucun commentaire:
Enregistrer un commentaire