-4

I have data like this:

userdata

I want to remove the rows in user ID_2 column which the data is more than and less than 5 digit

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ridwan K
  • 3
  • 1

2 Answers2

0

Select required column and check if value/10000 > 0 for more than 5 digit. Then replace that value with null or anything. Basically you are filtering data.

https://www.geeksforgeeks.org/python-filtering-data-with-pandas-query-method/

0

Since the question is

which the data is more than and less than 5 digit

Which means only 5 digits values are required, I slightly modified @ChrisA comment to fit the requirement:

df = pd.DataFrame({'userID': [20394756382,29304857203,20294857642,20293847564,20192837453],
                   'UserID2' : [38493,2212324,30498,30928,432]})

df = df.loc[df['UserID2'].astype(str).str.len().eq(5)]
print(df)
        userID  UserID2
0  20394756382    38493
2  20294857642    30498
3  20293847564    30928
ManojK
  • 1,570
  • 2
  • 9
  • 17