rstudio / rstudio/pins-python

What is the best way to read a pin from Posit Connect directly into polars?

Open
#233 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

.enhancement
Dominant language
Python
Stars
59
Forks
11
PR merge metrics
No merged PRs in 30d

Description

What is the best way to read a pin from Posit Connect directly into polars?

I have found a few options that work, but none of them are exactly what I am looking for.

(1) Use pin_download

This method is my favourite, but it requires one extra step, I can't get a polars dataframe directly from pin_read.

import pins
import polars as pl

board = pins.board_connect()
paths = board.pin_download("sam.edwardes/vessel_verbose_raw")
pl.read_parquet(paths)

(2) Use pandas

This works, but requires me to have pandas installed. I also assume there is some kind of performance hit b/c you first read into pandas, then into polars?

import pins
import pandas as pd
import polars as pl

board = pins.board_connect()
pl.DataFrame(board.pin_read("sam.edwardes/vessel_verbose_raw"))

(3) Use fsspec

I have not figured out how to implement this yet, but I found this example for duckdb:

https://github.com/rstudio/pins-python/pull/193

Is there a way to do this with polars?

Related issues

Suggestions

It would be nice if pins gave me a choice about what DataFrame library is used with pin_read. For example:

import pins
import polars as pl

board = pins.board_connect()
board.pin_read("sam.edwardes/vessel_verbose_raw", df_library='polars')

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing pin_read and pin_download behavior, then compare the fsspec approach in pull request 193 and the related issues 153 and 32. Determine whether direct Posit Connect reads can support polars without pandas, and consider how a DataFrame-library choice would fit the current API; done means a clear supported approach or implementation path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.