Comments (5)
Hey! Thanks for your explanation - if formulaic
requires specifically pandas input/output, and then that might be a good candidate for Narwhalification :) I'll take a look, thanks!
# another copy? potentially costly? Y = nw.from_native(Y)
Just to clarify, from_native
just wraps a dataframe in a narwhals.DataFrame
- it's a virtually free operation, only takes a few microseconds, and doesn't do any copies - Narwhals only translates syntax
from pyfixest.
Naive question: It seems formulaic supports pyarrow.Table
. Could this be a shortcut for Polars integration? https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.to_arrow.html
from pyfixest.
Hey, just wanted to stop by and say - thanks for your interest! Feel free to book some time on https://calendly.com/marcogorelli if you'd like to chat about how Narwhals could help PyFixest
from pyfixest.
Hi both (@MarcoGorelli and @juanitorduz) - I've now thought about it for 15 minutes and I think narwhals
might be a great solution for PyFixest
! Thanks for offering to chat @MarcoGorelli , I'll book an appointment =)
Just some background on pyfixest and how it works with Data Frames: most of the data manipulation happens via the formulaic library, which requires an input pd.DataFrame
. I.e. a usual flow looks like this:
%load_ext autoreload
%autoreload 2
import polars as pl
import pandas as pd
import pyfixest as pf
from formulaic import model_matrix
import narwhals as nw
data = pl.DataFrame(pf.get_data())
def feols(data):
if isinstance(data, pl.DataFrame):
data = data.to_pandas()
# model_matrix requires a pandas DataFrame and returns a pandas DataFrame
Y, X = model_matrix("Y ~ X1", data = data, output = "pandas")
# some more pandas manipulations
Y.dropna(inplace = True)
X.dropna(inplace = True)
return Y.to_numpy(), X.to_numpy()
Via narwhals
, it could look as
def feols_nw(data, use_polars = False):
data = nw.from_native(data)
# model_matrix requires a pandas DataFrame and returns a pandas DataFrame
Y, X = model_matrix("Y ~ X1", data = data.to_pandas(), output = "pandas")
if use_polars:
# another copy? potentially costly?
Y = nw.from_native(Y)
X = nw.from_native(X)
# some more pandas manipulations
Y.dropna(inplace = True)
X.dropna(inplace = True)
return Y.to_numpy(), X.to_numpy()
from pyfixest.
totally!
from pyfixest.
Related Issues (20)
- Wildboottest: Incorrect Initiation of R vector -> incorrect results
- Contributing Documentation does not show full code blocks HOT 2
- Contributing Documentation Formatting Issue
- Extract covariance matrix from regression object HOT 8
- F-test in pyfixest HOT 9
- Helping demean() Fail Gracefully - Add a'fixef_iter' argument to feols() and fepois() HOT 1
- Examples Layout Docs HOT 3
- Feiv : More diagnostic tests on the first stage regression need to be added HOT 2
- Add note on `wald_test` method to `quickstart` (or even a new notebook)? HOT 2
- Add "lean" argument to `feols()` and `fepois()` HOT 4
- Publish `pyfixest` on conda
- Add `solver` argument to `feols()`, `fepois()` APIs HOT 5
- Support for weights as an optional parameter for did2s? HOT 4
- Add benchmarks against `linearmodels` and `fastreg` HOT 8
- Add default IV Diagnostics to `pf.summary()` and `pf.etable()` HOT 1
- installing via pip broken by stargazer HOT 4
- Adding Standard Error of Prediction HOT 6
- BUG: coefplot() and iplot() show only point estimates, no confidence intervals HOT 1
- Implementing outcome plot in panelview()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyfixest.