Example codes for comparing SPL, SQL, and Python

 

Sepcification

Since most Python codes will use the pandas and numpy packages, any Python code in this article imports the following packages at the beginning by default:

import pandas as pd
import numpy as np

Contents

1 Data object

https://c.scudata.com/article/1728996942077

https://c.scudata.com/article/1729055739251

2 Loop function

https://c.scudata.com/article/1729064569291

https://c.scudata.com/article/1729064660467

https://c.scudata.com/article/1729065526039

https://c.scudata.com/article/1729065654559

https://c.scudata.com/article/1729065791226

3 Grouping operations

https://c.scudata.com/article/1729070112838

https://c.scudata.com/article/1729070225229

https://c.scudata.com/article/1729070314205

https://c.scudata.com/article/1729070474529

4 Aggregation operations

https://c.scudata.com/article/1729154065380

https://c.scudata.com/article/1729154155588

https://c.scudata.com/article/1729154235068

https://c.scudata.com/article/1729154304634

5 Iterative operations

https://c.scudata.com/article/1729156420896

https://c.scudata.com/article/1729156470278

https://c.scudata.com/article/1729156570325

6 Position and select

https://c.scudata.com/article/1729246440208

https://c.scudata.com/article/1729246510138

https://c.scudata.com/article/1729246580769

7 Sort and transpose

https://c.scudata.com/article/1733285058501

https://c.scudata.com/article/1733285623309

https://c.scudata.com/article/1733285768026

https://c.scudata.com/article/1733286648533

https://c.scudata.com/article/1733286898175

8 Join operations

https://c.scudata.com/article/1733294885219

https://c.scudata.com/article/1733295040902

https://c.scudata.com/article/1733295172276

9 Comprehensive examples

User Session Count
Count the players who score 3 times in a row within 1 minute
Calculate the number of users who are active for three consecutive days within every 7 days
Calculate the next-day retention rate of new users per day
Calculate the increase of stock price on the day when it is higher than those on the previous and next 5 days