Exemplo n.º 1
0
def test_index_copy_datetime(name, dtype, deep=True):
    cidx = cudf.DatetimeIndex(["2001", "2002", "2003"])
    pidx = cidx.to_pandas()

    pidx_copy = pidx.copy(name=name, deep=deep, dtype=dtype)
    cidx_copy = cidx.copy(name=name, deep=deep, dtype=dtype)

    # By default, cudf.DatetimeIndex uses [ms] as base unit, pandas uses [ns]
    if dtype == "int64":
        cidx_copy = cidx_copy * 1000000
    assert_eq(pidx_copy, cidx_copy)
Exemplo n.º 2
0
 def _load(self):
     print('Loading Environment...')
     csv_file = "/media/alan/seagate/Downloads/Binance_BTCUSDT_minute.csv"
     columns = ['Date', 'Open', 'High', 'Low', 'Close', 'Volume']
     if self.usd_cuda:
         df = cudf.read_csv(csv_file)
     else:
         df = pd.read_csv(csv_file)
     df = df.drop(columns=['unix', 'symbol', 'Volume USDT', 'tradecount::'])
     df.columns = columns
     if self.usd_cuda:
         df.index = cudf.DatetimeIndex(df['Date'])
     else:
         df.index = pd.DatetimeIndex(df['Date'])
     df = df.drop(columns=['Date', 'Volume'])
     df = df.dropna()
     df = df[::-1]
     data = df.values
     return data
Exemplo n.º 3
0
@pytest.mark.parametrize("dtype", NUMERIC_TYPES + ["category"])
def test_index_copy_category(name, dtype, deep=True):
    cidx = cudf.core.index.CategoricalIndex([1, 2, 3])
    pidx = cidx.to_pandas()

    pidx_copy = pidx.copy(name=name, deep=deep, dtype=dtype)
    cidx_copy = cidx.copy(name=name, deep=deep, dtype=dtype)

    assert_eq(pidx_copy, cidx_copy)


@pytest.mark.parametrize("deep", [True, False])
@pytest.mark.parametrize(
    "idx",
    [
        cudf.DatetimeIndex(["2001", "2002", "2003"]),
        cudf.core.index.StringIndex(["a", "b", "c"]),
        cudf.Int64Index([1, 2, 3]),
        cudf.Float64Index([1.0, 2.0, 3.0]),
        cudf.CategoricalIndex([1, 2, 3]),
        cudf.CategoricalIndex(["a", "b", "c"]),
    ],
)
def test_index_copy_deep(idx, deep):
    """Test if deep copy creates a new instance for device data.
    The general criterion is to compare `Buffer.ptr` between two data objects.
    Specifically for:
        - CategoricalIndex, this applies to both `.codes` and `.categories`
        - StringIndex, to every element in `._base_children`
        - Others, to `.base_data`
    No test is defined for RangeIndex.