|
| 1 | +""" |
| 2 | +Testing that we work in the downstream packages |
| 3 | +""" |
| 4 | +import pytest |
| 5 | +import numpy as np # noqa |
| 6 | +from pandas import DataFrame |
| 7 | +from pandas.util import testing as tm |
| 8 | + |
| 9 | + |
| 10 | +@pytest.fixture |
| 11 | +def df(): |
| 12 | + return DataFrame({'A': [1, 2, 3]}) |
| 13 | + |
| 14 | + |
| 15 | +def test_dask(df): |
| 16 | + |
| 17 | + toolz = pytest.importorskip('toolz') # noqa |
| 18 | + dask = pytest.importorskip('dask') # noqa |
| 19 | + |
| 20 | + import dask.dataframe as dd |
| 21 | + |
| 22 | + ddf = dd.from_pandas(df, npartitions=3) |
| 23 | + assert ddf.A is not None |
| 24 | + assert ddf.compute() is not None |
| 25 | + |
| 26 | + |
| 27 | +def test_xarray(df): |
| 28 | + |
| 29 | + xarray = pytest.importorskip('xarray') # noqa |
| 30 | + |
| 31 | + assert df.to_xarray() is not None |
| 32 | + |
| 33 | + |
| 34 | +def test_statsmodels(): |
| 35 | + |
| 36 | + statsmodels = pytest.importorskip('statsmodels') # noqa |
| 37 | + import statsmodels.api as sm |
| 38 | + import statsmodels.formula.api as smf |
| 39 | + df = sm.datasets.get_rdataset("Guerry", "HistData").data |
| 40 | + smf.ols('Lottery ~ Literacy + np.log(Pop1831)', data=df).fit() |
| 41 | + |
| 42 | + |
| 43 | +def test_scikit_learn(df): |
| 44 | + |
| 45 | + sklearn = pytest.importorskip('sklearn') # noqa |
| 46 | + from sklearn import svm, datasets |
| 47 | + |
| 48 | + digits = datasets.load_digits() |
| 49 | + clf = svm.SVC(gamma=0.001, C=100.) |
| 50 | + clf.fit(digits.data[:-1], digits.target[:-1]) |
| 51 | + clf.predict(digits.data[-1:]) |
| 52 | + |
| 53 | + |
| 54 | +def test_seaborn(): |
| 55 | + |
| 56 | + seaborn = pytest.importorskip('seaborn') |
| 57 | + tips = seaborn.load_dataset("tips") |
| 58 | + seaborn.stripplot(x="day", y="total_bill", data=tips) |
| 59 | + |
| 60 | + |
| 61 | +def test_pandas_gbq(df): |
| 62 | + |
| 63 | + pandas_gbq = pytest.importorskip('pandas-gbq') # noqa |
| 64 | + |
| 65 | + |
| 66 | +@tm.network |
| 67 | +def test_pandas_datareader(): |
| 68 | + |
| 69 | + pandas_datareader = pytest.importorskip('pandas-datareader') # noqa |
| 70 | + pandas_datareader.get_data_yahoo('AAPL') |
| 71 | + |
| 72 | + |
| 73 | +def test_geopandas(): |
| 74 | + |
| 75 | + geopandas = pytest.importorskip('geopandas') # noqa |
| 76 | + fp = geopandas.datasets.get_path('naturalearth_lowres') |
| 77 | + assert geopandas.read_file(fp) is not None |
| 78 | + |
| 79 | + |
| 80 | +def test_pyarrow(df): |
| 81 | + |
| 82 | + pyarrow = pytest.importorskip('pyarrow') # noqa |
| 83 | + table = pyarrow.Table.from_pandas(df) |
| 84 | + result = table.to_pandas() |
| 85 | + tm.assert_frame_equal(result, df) |
0 commit comments