Comments (5)
Interesting, thanks @hdoupe. Based on this and some more poking around the code, looks like this is how pandas
treats fastparquet
:
- Include as a dep in
environment.yml
- Don't include in
setup.py
- Use an
import_optional_dependency
function inpandas.compat._optional
, which is used elsewhere internally (this also specifies the minimum version for optional deps) - Call
import_optional_dependency
into_parquet
andread_parquet
inparquet.py
(through a couple intermediate steps) - In
test_parquet.py
, check if it's installed with atry
statement and skip tests if it isn't
I'll mirror this approach.
from microdf.
Pandas handles its optional/soft fastparquet dependency like this:
In [1]: import pandas as pd
In [2]: df = pd.read_parquet("matchups/statcast2018.parquet", engine="fastparquet")
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-284dbcb9c5fc> in <module>
----> 1 df = pd.read_parquet("matchups/statcast2018.parquet", engine="fastparquet")
~/miniconda3/lib/python3.7/site-packages/pandas/io/parquet.py in read_parquet(path, engine, columns, **kwargs)
293 """
294
--> 295 impl = get_engine(engine)
296 return impl.read(path, columns=columns, **kwargs)
~/miniconda3/lib/python3.7/site-packages/pandas/io/parquet.py in get_engine(engine)
42 return PyArrowImpl()
43 elif engine == "fastparquet":
---> 44 return FastParquetImpl()
45
46
~/miniconda3/lib/python3.7/site-packages/pandas/io/parquet.py in __init__(self)
139 # we need to import on first use
140 fastparquet = import_optional_dependency(
--> 141 "fastparquet", extra="fastparquet is required for parquet support."
142 )
143 self.api = fastparquet
~/miniconda3/lib/python3.7/site-packages/pandas/compat/_optional.py in import_optional_dependency(name, extra, raise_on_missing, on_version)
91 except ImportError:
92 if raise_on_missing:
---> 93 raise ImportError(message.format(name=name, extra=extra)) from None
94 else:
95 return None
ImportError: Missing optional dependency 'fastparquet'. fastparquet is required for parquet support. Use pip or conda to install fastparquet.
In [3]:
If you wanted to do something like this, then you could add a note to the install instructions telling people that taxcalc should be installed separately.
One thing to note is that Pandas can still read parquet files without other packages like fastpaquet being installed.
from microdf.
For completeness, here's the current error when importing microdf
without having taxcalc
installed:
import microdf
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-15236528f5d7> in <module>()
----> 1 import microdf
1 frames
/usr/local/lib/python3.6/dist-packages/microdf/taxcalc.py in <module>()
1 import microdf as mdf
----> 2 import taxcalc as tc
3
4
5 def static_baseline_calc(recs, year):
ModuleNotFoundError: No module named 'taxcalc'
from microdf.
Importing microdf
now works when taxcalc
isn't installed.
from microdf.
Thanks again, @hdoupe for the guidance here!
from microdf.
Related Issues (20)
- Use common sample MicroDataFrames across tests
- Implement MicroDataFrame.reset_index(inplace=True)
- Copying a MicroDataFrame changes columns in the original to Series
- Deprecate MicroDataFrame.set_weight_col HOT 1
- Subsetting a MicroDataFrame doesn't subset weights
- Micro{Series,DataFrame}.drop() returns {Series,DataFrame}
- Add pandas args to overridden methods
- Skip non-numeric columns when aggregating MicroDataFrames HOT 1
- Merging MicroDataFrames produces error
- Add MicroSeries.sqrt
- Add optional description property to MicroSeries
- Move to black linting in GitHub Action and add black precommit HOT 1
- Add __getattr__ override to MicroDataFrame HOT 3
- Example of the MicroSeries.rank function
- Add semantic versioning tools
- MicroDataFrame.astype(...) should return MicroDataFrame
- Transfer to PolicyEngine GitHub organization
- RuntimeWarning: invalid value encountered in true_divide
- Remove data visualization functionality
- DeprecationWarning around Pyarrow dependency for pandas
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 microdf.