<jupyter_start><jupyter_text>Time Series Slicing & Interpolations Initialization<jupyter_code># Importing verticapy
import verticapy as vp
# Creating a connection
vp.new_connection({"host": "10.211.55.14", 
                   "port": "5433", 
                   "database": "testdb", 
                   "password": "<PASSWORD>", 
                   "user": "dbadmin"},
                   name = "VerticaDSN")
vp.__version__
from verticapy.utilities import create_schema, drop
drop("smart_meters", method="schema")
create_schema("smart_meters")<jupyter_output><empty_output><jupyter_text>Dataset Ingestion<jupyter_code>from verticapy.utilities import read_csv
# Ingesting the 2 data sources: weather % smart meters consumptions
consumption = read_csv("smart_meters/sm_consumption.csv",
                       table_name = "consumption",
                       schema = "smart_meters",
                       parse_n_lines = 1000)
weather = read_csv("smart_meters/sm_weather.csv",
                   table_name = "weather",
                   schema = "smart_meters",
                   parse_n_lines = 1000)<jupyter_output>The table "smart_meters"."consumption" has been successfully created.
The table "smart_meters"."weather" has been successfully created.<jupyter_text>Data Exploration<jupyter_code>display(consumption)
display(weather)<jupyter_output><empty_output><jupyter_text>Time Series Slicing<jupyter_code># Slicing and creating regular time intervals
interpolate = consumption.interpolate(ts = "dateUTC",
                                      rule = "30 minutes",
                                      method = {"value": "linear"},
                                      by = ["meterID"])
display(interpolate)
print(interpolate.current_relation())
interpolate.join(weather,
                 how = "left",
                 on = {"dateUTC": "dateUTC"},
                 expr2 = ["temperature", "humidity"])<jupyter_output><empty_output><jupyter_text>Time Series Join<jupyter_code># Time Series Joins
ts_join = consumption.join(weather,
                           how = "left",
                           on_interpolate = {"dateUTC": "dateUTC"},
                           expr2 = ["temperature", "humidity"])
display(ts_join)
print(ts_join.current_relation())<jupyter_output>(
   SELECT
     "meterID",
     "dateUTC",
     "value",
     "temperature",
     "humidity" 
   FROM
 (
   SELECT
     x.*,
     y.temperature,
     y.humidity 
   FROM
 "smart_meters"."consumption" AS x LEFT JOIN "smart_meters"."weather" AS y  ON x."dateUTC" INTERPOLATE PREVIOUS VALUE y."dateUTC") 
VERTICAPY_SUBTABLE) 
VERTICAPY_SUBTABLE
{'fraction_non_alphanumeric': 0.10895238095238095, 'fraction_numerical': 0.009904761904761904, 'mean_word_length': 2.5630936227951153, 'pattern_counts': {'":': 8, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '102507', 'license': 'Apache-2.0', 'n_tokens_mistral': 825, 'n_tokens_neox': 763, 'n_words': 154, 'path': 'examples/data-preparation/ts.ipynb', 'repo_name': 'vertica/vertica_ml_python', 'size': '2618'}