def test_categoricals(): df = pd.DataFrame({'a': pd.Categorical(['Alice', 'Bob', 'Alice']), 'b': pd.Categorical([1, 2, 3])}) pf = pframe(like=df, blockdivs=[2]) pf.append(df) assert pf.partitions[0].blocks['a'].dtype == 'i1' tm.assert_frame_equal(pf.to_dataframe(), df)
def test_categoricals(): df = pd.DataFrame({ 'a': pd.Categorical(['Alice', 'Bob', 'Alice']), 'b': pd.Categorical([1, 2, 3]) }) pf = pframe(like=df, divisions=[2]) pf.append(df) assert pf.partitions[0].blocks['a'].dtype == 'i1' tm.assert_frame_equal(pf.to_dataframe(), df)
def test_raise_on_object_dtype(): df = pd.DataFrame({'a': ['Alice', 'Bob', 'Alice']}) assert raises(Exception, lambda: pframe(like=df, blockdivs=['Bob']))
import pandas as pd import shutil from pandas.util import testing as tm from pframe.utils import raises df1 = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [1., 2., 3.]}, index=[1, 3, 5]) df2 = pd.DataFrame({'a': [10, 20, 30], 'b': [40, 50, 60], 'c': [10., 20., 30.]}, index=[2, 4, 6]) df1.index.name = 'i' df2.index.name = 'i' pf = pframe(like=df1, blockdivs=[4]) pf.append(df1) pf.append(df2) def test_append(): a = pd.DataFrame({'a': [1, 2, 10], 'b': [4, 5, 40], 'c': [1., 2., 10.]}, index=[1, 3, 2]) a.index.name = 'i' b = pd.DataFrame({'a': [3, 20, 30], 'b': [6, 50, 60], 'c': [3., 20., 30.]}, index=[5, 4, 6]) b.index.name = 'i' tm.assert_frame_equal(pf.get_partition(0), a)
import shutil from pandas.util import testing as tm from pframe.utils import raises import pickle df1 = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [1., 2., 3.]}, index=[1, 3, 5]) df2 = pd.DataFrame({'a': [10, 20, 30], 'b': [40, 50, 60], 'c': [10., 20., 30.]}, index=[2, 4, 6]) df1.index.name = 'i' df2.index.name = 'i' pf = pframe(like=df1, divisions=[4]) pf.append(df1) pf.append(df2) def test_append(): a = pd.DataFrame({'a': [1, 2, 10], 'b': [4, 5, 40], 'c': [1., 2., 10.]}, index=[1, 3, 2]) a.index.name = 'i' b = pd.DataFrame({'a': [3, 20, 30], 'b': [6, 50, 60], 'c': [3., 20., 30.]}, index=[5, 4, 6]) b.index.name = 'i' tm.assert_frame_equal(pf.get_partition(0), a)
def test_raise_on_object_dtype(): df = pd.DataFrame({'a': ['Alice', 'Bob', 'Alice']}) assert raises(Exception, lambda: pframe(like=df, divisions=['Bob']))
'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [1., 2., 3.] }, index=[1, 3, 5]) df2 = pd.DataFrame({ 'a': [10, 20, 30], 'b': [40, 50, 60], 'c': [10., 20., 30.] }, index=[2, 4, 6]) df1.index.name = 'i' df2.index.name = 'i' pf = pframe(like=df1, divisions=[4]) pf.append(df1) pf.append(df2) def test_append(): a = pd.DataFrame({ 'a': [1, 2, 10], 'b': [4, 5, 40], 'c': [1., 2., 10.] }, index=[1, 3, 2]) a.index.name = 'i' b = pd.DataFrame({ 'a': [3, 20, 30], 'b': [6, 50, 60],
'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [1., 2., 3.] }, index=[1, 3, 5]) df2 = pd.DataFrame({ 'a': [10, 20, 30], 'b': [40, 50, 60], 'c': [10., 20., 30.] }, index=[2, 4, 6]) df1.index.name = 'i' df2.index.name = 'i' pf = pframe(like=df1, blockdivs=[4]) pf.append(df1) pf.append(df2) def test_append(): a = pd.DataFrame({ 'a': [1, 2, 10], 'b': [4, 5, 40], 'c': [1., 2., 10.] }, index=[1, 3, 2]) a.index.name = 'i' b = pd.DataFrame({ 'a': [3, 20, 30], 'b': [6, 50, 60],