如何转换此SQL代码:
SELECT
COUNT(DISTINCT DATEn) as count (*)
FROM weather_data
WHERE cast (rain as integer) = 1
使用熊猫符号,如下所示:df.groupby(' rain')DATEn.sum()
答案 0 :(得分:1)
IIUC:
df.loc[pd.to_numeric(df['rain'], errors='coerce') == 1, 'DATEn'].nunique()