Nov-20-2020, 02:57 PM
I doubt S_ID column had whitespaces,
Sandeep.
GANGA SANDEEP KUMAR
import pandas as pd df=pd.read_excel(open('b111.xlsx', 'rb'),sheet_name='Sheet1') print(df) #adding len coluumn df['id_char_length']=df['id'].astype(str).map(len) print(df) #remove column df=df.drop(['id_char_length'],axis=1) #fiter without trim spaces df = df[df['id'] != '[]'] print(df) #filter with trim spaces df = df[df['id'].str.strip() != '[]'] print(df)
Output:C:\Users\sandeep\Downloads>py b11
active createdate createtime username id
0 True 2020-11-03 12:04:29 M001AE8 []
1 True 2020-11-03 12:04:29 M001AE8 []
2 True 2020-11-03 12:02:35 M001AF0 []
3 True 2019-06-11 01:32:12 M017A70 []
4 True 2020-10-22 09:09:06 S345678 ['S345678']
5 True 2020-10-22 09:09:06 S567456 ['S567456']
6 True 2020-03-16 07:41:05 S789077 ['S789077']
7 True 2020-03-16 07:41:05 S123456 ['S123456']
8 True 2014-07-05 06:38:59 SvcPcc []
9 True 2014-07-05 06:38:59 SvcPcc []
10 True 2020-07-27 12:15:24 SvcPcc []
active createdate createtime username id id_char_length
0 True 2020-11-03 12:04:29 M001AE8 [] 10 <<<<
1 True 2020-11-03 12:04:29 M001AE8 [] 2
2 True 2020-11-03 12:02:35 M001AF0 [] 2
3 True 2019-06-11 01:32:12 M017A70 [] 2
4 True 2020-10-22 09:09:06 S345678 ['S345678'] 11
5 True 2020-10-22 09:09:06 S567456 ['S567456'] 11
6 True 2020-03-16 07:41:05 S789077 ['S789077'] 11
7 True 2020-03-16 07:41:05 S123456 ['S123456'] 11
8 True 2014-07-05 06:38:59 SvcPcc [] 21 <<<<
9 True 2014-07-05 06:38:59 SvcPcc [] 2
10 True 2020-07-27 12:15:24 SvcPcc [] 2
active createdate createtime username id
0 True 2020-11-03 12:04:29 M001AE8 []
4 True 2020-10-22 09:09:06 S345678 ['S345678']
5 True 2020-10-22 09:09:06 S567456 ['S567456']
6 True 2020-03-16 07:41:05 S789077 ['S789077']
7 True 2020-03-16 07:41:05 S123456 ['S123456']
8 True 2014-07-05 06:38:59 SvcPcc []
active createdate createtime username id
4 True 2020-10-22 09:09:06 S345678 ['S345678']
5 True 2020-10-22 09:09:06 S567456 ['S567456']
6 True 2020-03-16 07:41:05 S789077 ['S789077']
7 True 2020-03-16 07:41:05 S123456 ['S123456']
Best Regards,Sandeep.
GANGA SANDEEP KUMAR