Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

polars-qt

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polars-qt

  • 0.1.25
  • PyPI
  • Socket score

Maintainers
1

polars_qt

PyPI

Useful Quant expressions for polars implemented by polars plugin.

Currently :

  • Rolling_rank expression

  • If-Then expression.

  • Calculate return of future using strategy signal

rolling_rank

import polars as pl
import polars_qt as pq
df = pl.DataFrame({
    'a': [5.2, 4.1, 6.3, None, 10, 4, 5],
})
df.with_columns(
    pq.rolling_rank(pl.col('a'), 4, min_periods=1, pct=True).alias('a_rank'),
    pl.col('a').qt.rolling_rank(4, pct=False, rev=True).alias('a_rank2')
)

shape: (7, 3)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ a    โ”† a_rank   โ”† a_rank2 โ”‚
โ”‚ ---  โ”† ---      โ”† ---     โ”‚
โ”‚ f64  โ”† f64      โ”† f64     โ”‚
โ•žโ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ก
โ”‚ 5.2  โ”† 1.0      โ”† null    โ”‚
โ”‚ 4.1  โ”† 0.5      โ”† 2.0     โ”‚
โ”‚ 6.3  โ”† 1.0      โ”† 1.0     โ”‚
โ”‚ null โ”† null     โ”† null    โ”‚
โ”‚ 10.0 โ”† 1.0      โ”† 1.0     โ”‚
โ”‚ 4.0  โ”† 0.333333 โ”† 3.0     โ”‚
โ”‚ 5.0  โ”† 0.666667 โ”† 2.0     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

If-then

df = pl.DataFrame({
    'g': ['a', 'a', 'b', 'a', 'b'],
    'v': [1, 3, 5, 2, 4],
})
df.select(pl.col('v').qt.if_then((pl.len()>2), pl.col('v')*2).over('g'))

shape: (5, 1)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”
โ”‚ v   โ”‚
โ”‚ --- โ”‚
โ”‚ i64 โ”‚
โ•žโ•โ•โ•โ•โ•โ•ก
โ”‚ 2   โ”‚
โ”‚ 6   โ”‚
โ”‚ 5   โ”‚
โ”‚ 4   โ”‚
โ”‚ 4   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”˜

้€‚็”จไบŽ้‡‘่ž้‡ๅŒ–้ข†ๅŸŸ็š„polars่กจ่พพๅผๆ‰ฉๅฑ•๏ผŒไฝฟ็”จpolars pluginๅฎž็Žฐใ€‚

็›ฎๅ‰ๆ”ฏๆŒ๏ผš

  • ๆปšๅŠจๆŽ’ๅบ
  • if_then่กจ่พพๅผ
  • ๅˆฉ็”จ็ญ–็•ฅไฟกๅทๅ›žๆต‹ๆ”ถ็›Š

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc