为什么当过滤器为 BEGIN TRANSACTION
UPDATE VolumeLicenses SET TotalLicenses = TotalLicenses WHERE LicenseId = 901
IF ( SELECT COUNT(*) FROM VolumeLicenseUsers WHERE LicenseId = 901 ) < ( SELECT TotalLicenses FROM VolumeLicenses WHERE LicenseId = 901 )
BEGIN
INSERT INTO VolumeLicenseUsers ( LicenseId, UserId ) VALUES ( 901, 'John' )
COMMIT TRANSACTION
END
ELSE
BEGIN
--Add your Error Handing here
ROLLBACK TRANSACTION
END
==无时,此过滤无效?我还注意到Project ID
而不是is None
返回== None
KeyError: False
输出:
import pandas as pd
df = pd.DataFrame(data = [['Project1', 'CT', 800], [None, 3, 1000], ['Project3', 'CA', 20]], columns=['Project ID', 'State', 'Cost'])
print df.loc[df['Project ID'] == 'Project1'].values
print df.loc[df['Project ID'] == None].values
答案 0 :(得分:2)
您必须使用isnull
:
In [3]:
df[df['Project ID'].isnull()]
Out[3]:
Project ID State Cost
1 None 3 1000
或使用apply
:
In [5]:
df.loc[df['Project ID'].apply(lambda x: x is None)]
Out[5]:
Project ID State Cost
1 None 3 1000
答案 1 :(得分:0)
只是详细说明,它不起作用,因为pandas
使用np.nan
,并且:
print np.nan == np.nan # False
print np.nan == None # False
print np.isnan(np.nan) # True