我正在尝试根据我的列之一中的数组元素对雪花中的 SQL 查询进行子集化,但不确定如何执行此操作。
例如,如果 column2 是一个数组数据类型,如下所示
SELECT column2
FROM table
LIMIT 7;
Run Code Online (Sandbox Code Playgroud)
与输出:
Row column2
1 ["cats","dogs"]
2 ["horses","cows","cats"]
3 NULL
4 ["dogs","fish]
5 ["birds"]
6 ["cats"]
7 NULL
Run Code Online (Sandbox Code Playgroud)
我想对数据进行子集化并运行一个查询,该查询会拉入第 2 列中任何数组中任何具有“cats”元素的行 - 所以第 1,2 行和第 6 行 - 我将如何构建该查询?
使用这样的东西是行不通的:
SELECT column1, column2, column3
FROM Table
WHERE column2 = "cats" (or using an IN statement)
Run Code Online (Sandbox Code Playgroud)
并导致错误消息为无效标识符“cats”,这是我所期望的,因为它位于数组中
任何见解将不胜感激!
我正在尝试使用葡萄酒评论数据集进行沙箱项目,并希望将文本数据以及一些工程数字特征组合到神经网络中,但我收到了一个值错误。
我拥有的三组功能是描述(实际评论)、按比例调整的价格和按比例调整的字数(描述的长度)。我将 y 目标变量转换为代表好评或差评的二分变量,将其转化为分类问题。
这些是否是最好使用的功能并不是重点,但我希望尝试将 NLP 与元数据或数值数据结合起来。当我仅使用描述运行代码时,它工作正常,但添加其他变量会导致值错误。
y = df['y']
X = df.drop('y', axis=1)
# split up the data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)
X_train.head();
description_train = X_train['description']
description_test = X_test['description']
#subsetting the numeric variables
numeric_train = X_train[['scaled_price','scaled_num_words']].to_numpy()
numeric_test = X_test[['scaled_price','scaled_num_words']].to_numpy()
MAX_VOCAB_SIZE = 60000
tokenizer = Tokenizer(num_words=MAX_VOCAB_SIZE)
tokenizer.fit_on_texts(description_train)
sequences_train = tokenizer.texts_to_sequences(description_train)
sequences_test = tokenizer.texts_to_sequences(description_test)
word2idx = tokenizer.word_index
V = len(word2idx)
print('Found %s unique tokens.' % V)
Found 31598 unique tokens.
nlp_train = pad_sequences(sequences_train)
print('Shape of data train …Run Code Online (Sandbox Code Playgroud)