pd.read_sql_query("""SELECT Tab1.Title, NewTab.NewCol1 FROM
(SELECT Col1 AS NewCol, COUNT(*) AS NewCol1
FROM Tab2 GROUP BY Col1) AS NewTab
JOIN Tab1 ON NewTab.NewCol=Tab1.Id
WHERE Tab1.Num=1
ORDER BY NewCol1 DESC""", conn)
My goal is to rewrite it using only pandas' methods and functions. First things first, I'd like to assign a new column NewCol that would contain also a new column PostId, but I highly doubt that I should do it in two steps. Could anyone please guide me towards solution or provide a full code I could analyze?