def test_vDF_to_vdf(self, titanic_vd):
     session_id = get_session(titanic_vd._VERTICAPY_VARIABLES_["cursor"])
     titanic_vd.to_vdf("verticapy_test_{}".format(session_id))
     try:
         result = read_vdf(
             "verticapy_test_{}.vdf".format(session_id),
             cursor=titanic_vd._VERTICAPY_VARIABLES_["cursor"],
         )
     except:
         result = False
     os.remove("verticapy_test_{}.vdf".format(session_id))
     assert isinstance(result, vDataFrame)
     assert result.shape() == (1234, 14)
 def test_vDF_to_csv(self, titanic_vd):
     session_id = get_session(titanic_vd._VERTICAPY_VARIABLES_["cursor"])
     titanic_vd.copy().select(["age", "fare"]).sort({"age": "desc", "fare": "desc"})[0:2].to_csv("verticapy_test_{}".format(session_id))
     try:
         file = open("verticapy_test_{}.csv".format(session_id), "r")
         result = file.read()
         assert result == 'age,fare\n80.000,30.00000\n76.000,78.85000'
     except:
         os.remove("verticapy_test_{}.csv".format(session_id))
         file.close()
         raise
     os.remove("verticapy_test_{}.csv".format(session_id))
     file.close()
 def test_vDF_to_json(self, titanic_vd):
     session_id = get_session(titanic_vd._VERTICAPY_VARIABLES_["cursor"])
     titanic_vd.copy().select(["age", "fare"]).sort({"age": "desc", "fare": "desc"})[0:2].to_json("verticapy_test_{}".format(session_id))
     try:
         file = open("verticapy_test_{}.json".format(session_id), "r")
         result = file.read()
         print(result)
         assert result == '[\n{"age": 80.000, "fare": 30.00000},\n{"age": 76.000, "fare": 78.85000},\n]'
     except:
         os.remove("verticapy_test_{}.json".format(session_id))
         file.close()
         raise
     os.remove("verticapy_test_{}.json".format(session_id))
     file.close()
示例#4
0
 def test_vDF_to_json(self, titanic_vd):
     session_id = get_session()
     titanic_vd.copy().select(["age", "fare"]).sort({"age": "desc", "fare": "desc"})[
         0:2
     ].to_json("verticapy_test_to_json.json")
     try:
         file = open("verticapy_test_to_json.json", "r")
         result = file.read()
         assert (
             result
             == '[\n{"age": 80.000, "fare": 30.00000},\n{"age": 76.000, "fare": 78.85000},\n]'
         )
     except:
         os.remove("verticapy_test_to_json.json")
         file.close()
         raise
     os.remove("verticapy_test_to_json.json")
     file.close()
示例#5
0
 def test_vDF_to_parquet(self, titanic_vd):
     session_id = get_session()
     name = "parquet_test_{}".format(session_id)
     result = titanic_vd.to_parquet(name)
     assert result["Rows Exported"][0] == 1234