由apache arrow支持的pandas扩展类型/数组
fletcher的Python项目详细描述
弗莱彻
提供泛型pandas扩展类型/数组集的库 由apache arrow支持的实现。它们支持更广泛的类型 比大熊猫天生的支持,也带来了不同的约束和 在许多情况下有益的行为。
用法
要在pandas数据帧中使用fletcher
,只需包装数据
在FletcherArray
对象中。您的数据可以是pyarrow.Array
,
pyarrow.ChunkedArray
或可传递给pyarrow.array(…)
的类型。
import fletcher as fr
import pandas as pd
df = pd.DataFrame({
'str': fr.FletcherArray(['a', 'b', 'c'])
})
df.info()
# RangeIndex: 3 entries, 0 to 2
# Data columns (total 1 columns):
# str 3 non-null fletcher[string]
# dtypes: fletcher[string](1)
# memory usage: 100.0 bytes
开发
虽然可以在基于pip的环境中使用fletcher
,但我们强烈建议
对来自conda-forge
的包使用基于conda
的开发设置。
# Create the conda environment with all necessary dependencies
conda create -y -q -n fletcher python=3.6 \
black=18.5b0 \
codecov \
flake8 \
numba \
pandas \
pip \
pyarrow \
pytest \
pytest-cov \
pytest-flake8 \
six \
-c conda-forge
# Activate the newly created environment
source activate fletcher
# Install fletcher into the current environment
pip install -e .
# Run the unit tests (you should do this several times during development)
py.test
代码格式化使用黑色完成。这应该能让一切
一致的样式和格式可以使用
black .
。注意,我们已经锁定了black
的版本,以确保
格式是可复制的。