Advertisement
AnnaCh1971

Задача 6 в проекте активных дней на пользователя

Jun 7th, 2023
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. query = '''
  2. SELECT user_id,
  3.       COUNT (counts) AS counts_per_user
  4. FROM (SELECT user_id,
  5.             count (id) AS active_days,
  6.              DATE_TRUNC('day', creation_date::date) AS day
  7.       FROM stackoverflow.posts
  8.       WHERE creation_date::date BETWEEN '2008-12-01' AND '2008-12-07'
  9.       GROUP BY user_id, DATE_TRUNC('day', creation_date::date)
  10.       ORDER BY day) AS counts
  11.       GROUP BY user_id
  12. '''
  13.  
  14. test =  pd.read_sql_query(query, con=engine)
  15. test.head(10)
  16. test
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement