Igor dias
Igor dias

Reputation: 35

Transform SQL code in Pandas notation

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

Answers (1)

MaxU - stand with Ukraine
MaxU - stand with Ukraine

Reputation: 210882

IIUC:

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

Upvotes: 1

Related Questions