コード例 #1
0
def amazon_vd(base):
    from verticapy.datasets import load_amazon

    amazon = load_amazon(cursor=base.cursor)
    yield amazon
    with warnings.catch_warnings(record=True) as w:
        drop(name="public.titanic", cursor=base.cursor)
コード例 #2
0
def iris_vd(base):
    from verticapy.datasets import load_iris

    iris = load_iris(cursor=base.cursor)
    yield iris
    with warnings.catch_warnings(record=True) as w:
        drop(name="public.iris", cursor=base.cursor)
コード例 #3
0
def winequality_vd(base):
    from verticapy.datasets import load_winequality

    winequality = load_winequality(cursor=base.cursor)
    yield winequality
    with warnings.catch_warnings(record=True) as w:
        drop(name="public.winequality", cursor=base.cursor)
コード例 #4
0
def tr_data_vd(base):
    base.cursor.execute("DROP TABLE IF EXISTS public.tr_data")
    base.cursor.execute(
        'CREATE TABLE IF NOT EXISTS public.tr_data(Id INT, transportation INT, gender VARCHAR, "owned cars" INT, cost VARCHAR, income CHAR(4))'
    )
    base.cursor.execute(
        "INSERT INTO tr_data VALUES (1, 0, 'Male', 0, 'Cheap', 'Low')")
    base.cursor.execute(
        "INSERT INTO tr_data VALUES (2, 0, 'Male', 1, 'Cheap', 'Med')")
    base.cursor.execute(
        "INSERT INTO tr_data VALUES (3, 1, 'Female', 1, 'Cheap', 'Med')")
    base.cursor.execute(
        "INSERT INTO tr_data VALUES (4, 0, 'Female', 0, 'Cheap', 'Low')")
    base.cursor.execute(
        "INSERT INTO tr_data VALUES (5, 0, 'Male', 1, 'Cheap', 'Med')")
    base.cursor.execute(
        "INSERT INTO tr_data VALUES (6, 1, 'Male', 0, 'Standard', 'Med')")
    base.cursor.execute(
        "INSERT INTO tr_data VALUES (7, 1, 'Female', 1, 'Standard', 'Med')")
    base.cursor.execute(
        "INSERT INTO tr_data VALUES (8, 2, 'Female', 1, 'Expensive', 'Hig')")
    base.cursor.execute(
        "INSERT INTO tr_data VALUES (9, 2, 'Male', 2, 'Expensive', 'Med')")
    base.cursor.execute(
        "INSERT INTO tr_data VALUES (10, 2, 'Female', 2, 'Expensive', 'Hig')")
    base.cursor.execute("COMMIT")

    tr_data = vDataFrame(input_relation="public.tr_data", cursor=base.cursor)
    yield tr_data
    with warnings.catch_warnings(record=True) as w:
        drop(name="public.tr_data", cursor=base.cursor)
コード例 #5
0
def titanic_vd(base):
    from verticapy.datasets import load_titanic

    titanic = load_titanic(cursor=base.cursor)
    yield titanic
    with warnings.catch_warnings(record=True) as w:
        drop(name="public.titanic", cursor=base.cursor)
コード例 #6
0
def smart_meters_vd(base):
    from verticapy.datasets import load_smart_meters

    smart_meters = load_smart_meters(cursor=base.cursor)
    yield smart_meters
    with warnings.catch_warnings(record=True) as w:
        drop(name="public.smart_meters", cursor=base.cursor)
コード例 #7
0
def commodities_vd(base):
    from verticapy.datasets import load_commodities

    commodities = load_commodities(cursor=base.cursor)
    yield commodities
    with warnings.catch_warnings(record=True) as w:
        drop(name="public.commodities", cursor=base.cursor)
コード例 #8
0
def market_vd(base):
    from verticapy.datasets import load_market

    market = load_market(cursor=base.cursor)
    yield market
    with warnings.catch_warnings(record=True) as w:
        drop(
            name="public.market", cursor=base.cursor,
        )
コード例 #9
0
def amazon_vd(base):
    from verticapy.datasets import load_amazon

    amazon = load_amazon(cursor=base.cursor)
    yield amazon
    drop(
        name="public.amazon",
        cursor=base.cursor,
    )
コード例 #10
0
def iris_vd(base):
    from verticapy.datasets import load_iris

    iris = load_iris(cursor=base.cursor)
    yield iris
    drop(
        name="public.iris",
        cursor=base.cursor,
    )
コード例 #11
0
def commodities_vd(base):
    from verticapy.datasets import load_commodities

    commodities = load_commodities(cursor=base.cursor)
    yield commodities
    drop(
        name="public.commodities",
        cursor=base.cursor,
    )
コード例 #12
0
def airline_vd(base):
    from verticapy.datasets import load_airline_passengers

    airline = load_airline_passengers(cursor=base.cursor)
    yield airline
    with warnings.catch_warnings(record=True) as w:
        drop(
            name="public.airline_passengers",
            cursor=base.cursor,
        )
コード例 #13
0
def gapminder_vd(base):
    from verticapy.datasets import load_gapminder

    gapminder = load_gapminder(cursor=base.cursor)
    yield gapminder
    with warnings.catch_warnings(record=True) as w:
        drop(
            name="public.gapminder",
            cursor=base.cursor,
        )
コード例 #14
0
def pop_growth_vd(base):
    from verticapy.datasets import load_pop_growth

    pop_growth = load_pop_growth(cursor=base.cursor)
    yield pop_growth
    with warnings.catch_warnings(record=True) as w:
        drop(
            name="public.pop_growth",
            cursor=base.cursor,
        )
コード例 #15
0
def world_vd(base):
    from verticapy.datasets import load_world

    cities = load_world(cursor=base.cursor)
    yield cities
    with warnings.catch_warnings(record=True) as w:
        drop(
            name="public.world",
            cursor=base.cursor,
        )
コード例 #16
0
 def test_create_verticapy_schema(self, base):
     with warnings.catch_warnings(record=True) as w:
         drop("verticapy", base.cursor, method="schema")
     create_verticapy_schema(base.cursor)
     base.cursor.execute(
         "SELECT table_name FROM columns WHERE table_schema = 'verticapy' GROUP BY 1 ORDER BY 1;"
     )
     result = [elem[0] for elem in base.cursor.fetchall()]
     assert result == ["attr", "models"]
     drop("verticapy", base.cursor, method="schema")
コード例 #17
0
 def test_vDF_to_shp(self, cities_vd):
     drop(name="public.cities_test")
     cities_vd.to_shp("cities_test", "/home/dbadmin/", shape="Point")
     vdf = read_shp("/home/dbadmin/cities_test.shp")
     assert vdf.shape() == (202, 3)
     try:
         os.remove("/home/dbadmin/cities_test.shp")
         os.remove("/home/dbadmin/cities_test.shx")
         os.remove("/home/dbadmin/cities_test.dbf")
     except:
         pass
     drop(name="public.cities_test")
コード例 #18
0
 def test_read_json(self, base):
     with warnings.catch_warnings(record=True) as w:
         drop(
             "public.titanic_verticapy_test",
             base.cursor,
         )
     result = read_json(
         os.path.dirname(verticapy.__file__) +
         "/tests/utilities/titanic-passengers.json",
         base.cursor,
         table_name="titanic_verticapy_test",
         schema="public",
     )
     assert result.shape() == (891, 15)
     drop("titanic_verticapy_test", base.cursor)
     with warnings.catch_warnings(record=True) as w:
         drop(
             "v_temp_schema.titanic_verticapy_test",
             base.cursor,
         )
     result = read_json(
         os.path.dirname(verticapy.__file__) +
         "/tests/utilities/titanic-passengers.json",
         base.cursor,
         table_name="titanic_verticapy_test",
     )
     assert result.shape() == (891, 15)
     drop("v_temp_schema.titanic_verticapy_test", base.cursor)
コード例 #19
0
 def test_pandas_to_vertica(self, titanic_vd):
     df = titanic_vd.to_pandas()
     with warnings.catch_warnings(record=True) as w:
         drop(
             "titanic_pandas",
             titanic_vd._VERTICAPY_VARIABLES_["cursor"],
         )
     vdf = pandas_to_vertica(
         df=df,
         cursor=titanic_vd._VERTICAPY_VARIABLES_["cursor"],
     )
     assert vdf.shape() == (1234, 14)
     drop(
         "titanic_pandas",
         titanic_vd._VERTICAPY_VARIABLES_["cursor"],
     )
コード例 #20
0
ファイル: test_stats.py プロジェクト: vertica/VerticaPy
 def test_cochrane_orcutt(self, airline_vd):
     airline_copy = airline_vd.copy()
     airline_copy["passengers_bias"] = (airline_copy["passengers"]**2 -
                                        50 * st.random())
     drop("lin_cochrane_orcutt_model_test", method="model")
     model = LinearRegression("lin_cochrane_orcutt_model_test")
     model.fit(airline_copy, ["passengers_bias"], "passengers")
     result = st.cochrane_orcutt(
         model,
         airline_copy,
         ts="date",
         prais_winsten=True,
     )
     assert result.coef_["coefficient"][0] == pytest.approx(
         25.8582027191416, 1e-2)
     assert result.coef_["coefficient"][1] == pytest.approx(
         0.00123563974547625, 1e-2)
     model.drop()
コード例 #21
0
def bsk_data_vd(base):
    base.cursor.execute("DROP TABLE IF EXISTS public.bsk_data")
    base.cursor.execute(
        "CREATE TABLE IF NOT EXISTS public.bsk_data(Id INT, col1 FLOAT, col2 FLOAT, col3 FLOAT, col4 FLOAT)"
    )
    base.cursor.execute("INSERT INTO bsk_data VALUES (1, 7.2, 3.6, 6.1, 2.5)")
    base.cursor.execute("INSERT INTO bsk_data VALUES (2, 7.7, 2.8, 6.7, 2.0)")
    base.cursor.execute("INSERT INTO bsk_data VALUES (3, 7.7, 3.0, 6.1, 2.3)")
    base.cursor.execute("INSERT INTO bsk_data VALUES (4, 7.9, 3.8, 6.4, 2.0)")
    base.cursor.execute("INSERT INTO bsk_data VALUES (5, 4.4, 2.9, 1.4, 0.2)")
    base.cursor.execute("INSERT INTO bsk_data VALUES (6, 4.6, 3.6, 1.0, 0.2)")
    base.cursor.execute("INSERT INTO bsk_data VALUES (7, 4.7, 3.2, 1.6, 0.2)")
    base.cursor.execute("INSERT INTO bsk_data VALUES (8, 6.5, 2.8, 4.6, 1.5)")
    base.cursor.execute("INSERT INTO bsk_data VALUES (9, 6.8, 2.8, 4.8, 1.4)")
    base.cursor.execute("INSERT INTO bsk_data VALUES (10, 7.0, 3.2, 4.7, 1.4)")
    base.cursor.execute("COMMIT")

    bsk_data = vDataFrame(input_relation="public.bsk_data", cursor=base.cursor)
    yield bsk_data
    with warnings.catch_warnings(record=True) as w:
        drop(name="public.bsk_data", cursor=base.cursor)
コード例 #22
0
 def test_vDF_to_shp(self, cities_vd):
     with warnings.catch_warnings(record=True) as w:
         drop(
             name="public.cities_test",
             cursor=cities_vd._VERTICAPY_VARIABLES_["cursor"],
         )
     cities_vd.to_shp("cities_test", "/home/dbadmin/", shape="Point")
     vdf = read_shp("/home/dbadmin/cities_test.shp",
                    cities_vd._VERTICAPY_VARIABLES_["cursor"])
     assert vdf.shape() == (202, 3)
     try:
         os.remove("/home/dbadmin/cities_test.shp")
         os.remove("/home/dbadmin/cities_test.shx")
         os.remove("/home/dbadmin/cities_test.dbf")
     except:
         pass
     with warnings.catch_warnings(record=True) as w:
         drop(
             name="public.cities_test",
             cursor=cities_vd._VERTICAPY_VARIABLES_["cursor"],
         )
コード例 #23
0
 def test_read_csv(self, base):
     with warnings.catch_warnings(record=True) as w:
         drop(
             "public.titanic_verticapy_test",
             base.cursor,
         )
     result = read_csv(os.path.dirname(verticapy.__file__) +
                       "/data/titanic.csv",
                       base.cursor,
                       table_name="titanic_verticapy_test",
                       schema="public")
     assert result.shape() == (1234, 14)
     with warnings.catch_warnings(record=True) as w:
         drop(
             "v_temp_schema.titanic_verticapy_test",
             base.cursor,
         )
     result = read_csv(
         os.path.dirname(verticapy.__file__) + "/data/titanic.csv",
         base.cursor,
         table_name="titanic_verticapy_test",
     )
     assert result.shape() == (1234, 14)
     drop("titanic_verticapy_test", base.cursor)
コード例 #24
0
def bsk_data_vd():
    bsk_data = load_dataset_num(table_name="bsk_data", schema="public")
    yield bsk_data
    drop(name="public.bsk_data", method="table")
コード例 #25
0
ファイル: test_svd.py プロジェクト: vertica/VerticaPy
def winequality_vd():
    winequality = load_winequality()
    yield winequality
    drop(name="public.winequality", )
コード例 #26
0
def winequality_vd(base):
    from verticapy.datasets import load_winequality

    winequality = load_winequality(cursor=base.cursor)
    yield winequality
    drop(name="public.winequality", cursor=base.cursor)
コード例 #27
0
def amazon_vd():
    amazon = load_amazon()
    yield amazon
    drop(name="public.amazon")
コード例 #28
0
def iris_vd():
    iris = load_iris()
    yield iris
    drop(name="public.iris", )
コード例 #29
0
def titanic_vd():
    titanic = load_titanic()
    yield titanic
    drop(name="public.titanic")
コード例 #30
0
def market_vd():
    market = load_market()
    yield market
    drop(name="public.market")