1. Numerical type numerical value judgment:
If not (p['Baidu Latitude']):
2. Character type judges the empty value
if xxx
None,’’,0,[],{},(), False are all judged as null values (not xxx equivalent)
The following code output shows,
if xxx is None
This writing method can be used at any time when you need to distinguish between the difference between null objects such as [], {}, ‘’, () and None.
3. Shaply judgment
selectall = selectall[~.is_empty]
4. Pandas automatic filling
Only single columns can be filled with none values
cphon['Baidu Longitude'].fillna('No Latitude and Longitude', inplace=True)
cphon['Baidu Latitude'].fillna('No Latitude and Longitude', inplace=True)
cphon['Baidu Border'] = cphon['Baidu Border'].apply(lambda x: 'Baidu Border' if str(x) == 'nan' else x)