Reputation: 35
How do I transform this SQL code:
SELECT
COUNT(DISTINCT DATEn) as count (*)
FROM weather_data
WHERE cast (rain as integer) = 1
using the Pandas notation, like this: df.groupby ('rain') DATEn.sum ()
Upvotes: 2
Views: 62
Reputation: 210882
IIUC:
df.loc[pd.to_numeric(df['rain'], errors='coerce') == 1, 'DATEn'].nunique()
Upvotes: 1