-1

Any way for rearranging the sorting of the failed logged in times according the number from smaller to larger? For example the first 5 rows is 3, 6th is 5 and last rows is 6.

Ip address with number failed logged in more than 2 times

ip_address
128.15.0.2                  **3**

126.11.0.8                  **3**

0:0:0:0:0:ffff:c001:101     **3**

192.168.1.5                 **5**

192.168.1.15                **6**

0:0:0:0:0:ffff:a093:1800    **3**

0:0:0:0:0:ffff:212:d        **3**
Mr-Programs
  • 767
  • 4
  • 20
  • 2
    Can you post the input data structure and expected output. – Rakesh Dec 03 '18 at 10:06
  • `print('\nIp address with number failed logged in more than 2 times ')` `print('------------------------------------------------------------')` `print(df2['num_failed_logins'])` Here is my code and I just want to know any way to sorting the output number from smaller to bigger. – JIN HONG LEONG Dec 03 '18 at 10:21
  • `AttributeError: 'DataFrame' object has no attribute 'sort'` Prompt out this error – JIN HONG LEONG Dec 03 '18 at 10:25
  • `df2.sort_values(['num_failed_logins'])` ? – Rakesh Dec 03 '18 at 10:29

1 Answers1

0

there are many ways. I found a fast way in this post post.

import numpy as np
x = np.array([["128.15.0.2",3],
["126.11.0.8",3],
["0:0:0:0:0:ffff:c001:101",3],
["192.168.1.5",5],
["192.168.1.15",6],
["0:0:0:0:0:ffff:a093:1800",3],
["0:0:0:0:0:ffff:212:d",3]])


x[x[:,1].argsort()]
JackByte
  • 96
  • 7