如何转换此SQL代码:

SELECT
   COUNT(DISTINCT DATEn) as count (*)
FROM weather_data
WHERE cast (rain as integer) = 1


使用Pandas表示法,如下所示:df.groupby('rain')DATEn.sum()

最佳答案

IIUC:

df.loc[pd.to_numeric(df['rain'], errors='coerce') == 1, 'DATEn'].nunique()

关于python - 以Pandas表示法转换SQL代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46820047/

10-12 22:14