Example #1
0
def test_asof_without_nan(dates, subset):
    data = {"a": [10, 20, 30, 40, 50], "b": [70, 600, 30, -200, 500]}
    index = pd.DatetimeIndex([
        "2018-02-27 09:01:00",
        "2018-02-27 09:02:00",
        "2018-02-27 09:03:00",
        "2018-02-27 09:04:00",
        "2018-02-27 09:05:00",
    ])
    modin_where = pd.DatetimeIndex(dates)
    pandas_where = pandas.DatetimeIndex(dates)
    compare_asof(data, index, modin_where, pandas_where, subset)
Example #2
0
def test_asof():
    df = pd.DataFrame(
        {
            "a": [10, 20, 30, 40, 50],
            "b": [None, None, None, None, 500]
        },
        index=pd.DatetimeIndex([
            "2018-02-27 09:01:00",
            "2018-02-27 09:02:00",
            "2018-02-27 09:03:00",
            "2018-02-27 09:04:00",
            "2018-02-27 09:05:00",
        ]),
    )
    with pytest.warns(UserWarning):
        df.asof(
            pd.DatetimeIndex(["2018-02-27 09:03:30", "2018-02-27 09:04:30"]))
Example #3
0
def test_reindex_like():
    df1 = pd.DataFrame(
        [
            [24.3, 75.7, "high"],
            [31, 87.8, "high"],
            [22, 71.6, "medium"],
            [35, 95, "medium"],
        ],
        columns=["temp_celsius", "temp_fahrenheit", "windspeed"],
        index=pd.date_range(start="2014-02-12", end="2014-02-15", freq="D"),
    )
    df2 = pd.DataFrame(
        [[28, "low"], [30, "low"], [35.1, "medium"]],
        columns=["temp_celsius", "windspeed"],
        index=pd.DatetimeIndex(["2014-02-12", "2014-02-13", "2014-02-15"]),
    )
    with pytest.warns(UserWarning):
        df2.reindex_like(df1)
Example #4
0
import numpy as np
#import pandas as pd
import ray
ray.init(huge_pages=False,
         plasma_directory="/localdisk/gashiman/plasma",
         memory=1024 * 1024 * 1024 * 200,
         object_store_memory=1024 * 1024 * 1024 * 200)
import modin.pandas as pd

df = pd.DataFrame([[2, np.datetime64('2013-08-01 08:14:37'), 1.1],
                   [5, np.datetime64('2014-08-01 09:13:00'), 2.2],
                   [8, np.datetime64('2015-08-01 09:48:00'), 3.3]],
                  index=[1, 2, 3],
                  columns=['health', 'timestamp', 'shield'])
print(df)

transformed = df[['health', 'timestamp', 'shield']].transform({
    'health':
    lambda x: x,
    'timestamp':
    lambda x: pd.DatetimeIndex(x).year,
    'shield':
    lambda x: x
}).groupby(['health', 'timestamp', 'shield'])
print(transformed)

df1 = transformed.size().reset_index().sort_values(by=['timestamp', 0],
                                                   ascending=[True, False])
print(df1)