我想使用另一个笔记本在数据块中运行笔记本%run。另外,我希望能够将我正在运行的笔记本的路径作为参数发送到主笔记本。
不使用的原因dbutils.notebook.run是我将嵌套字典存储在调用的笔记本中,并且我想在主笔记本中使用它们。
我正在寻找类似的东西:
path = "/References/parameterDefinition/schemaRepository"
Run Code Online (Sandbox Code Playgroud)
%run <path variable>
Run Code Online (Sandbox Code Playgroud) 我StringType()在 PySpark 数据框中有一列。我想从该字符串中提取正则表达式模式的所有实例,并将它们放入新的列中ArrayType(StringType())
假设正则表达式模式是[a-z]\*([0-9]\*)
Input df:
+-----------+
|stringValue|
+-----------+
|a1234bc123 |
|av1tb12h18 |
|abcd |
+-----------+
Output df:
+-----------+-------------------+
|stringValue|output |
+-----------+-------------------+
|a1234bc123 |['1234', '123'] |
|av1tb12h18 |['1', '12', '18'] |
|abcd |[] |
+-----------+-------------------+
Run Code Online (Sandbox Code Playgroud) 我正在使用火花2.4。
我在 Spark 数据框中有一个 ArrayType(StringType()) 列和一个 StringType() 列。我需要在 ArrayType(StringType()) 列中找到 StringType() 列的位置。
输入示例:
+---------------+---------+
|arrayCol |stringCol|
+---------------+---------+
|['a', 'b', 'c']|'b' |
+---------------+---------+
|['a', 'b', 'c']|'d' |
+---------------+---------+
Run Code Online (Sandbox Code Playgroud)
示例输出:
+---------------+---------+-----+
|arrayCol |stringCol|Index|
+---------------+---------+-----+
|['a', 'b', 'c']|'b' |2 |
+---------------+---------+-----+
|['a', 'b', 'c']|'d' |null |
+---------------+---------+-----+
Run Code Online (Sandbox Code Playgroud)
我尝试过 array_position 但它不起作用,并且出现“列不可迭代”错误。
我也尝试过组合 expr、transform 和 array_position,但我想知道是否有一个不需要使用 expr 的解决方案。
谢谢 :)
我ArrayType(StringType())在 Spark 数据框中有两列,我想按元素连接这两列:
输入:
+-------------+-------------+
|col1 |col2 |
+-------------+-------------+
|['a','b'] |['c','d'] |
|['a','b','c']|['e','f','g']|
+-------------+-------------+
Run Code Online (Sandbox Code Playgroud)
输出:
+-------------+-------------+----------------+
|col1 |col2 |col3 |
+-------------+-------------+----------------+
|['a','b'] |['c','d'] |['ac', 'bd'] |
|['a','b','c']|['e','f','g']|['ae','bf','cg']|
+-------------+----------- -+----------------+
Run Code Online (Sandbox Code Playgroud)
谢谢。