我需要将以下scala语句转换为python:
scala> a.join(b, a("key") === b("key"), "left").select(a.columns.map(a(_)) : _*).show
:
和_*
遇到麻烦
我对Scala不熟悉。
我需要在python中的此答案中实现解决方案: https://stackoverflow.com/a/43340781/2453657
答案 0 :(得分:1)
在Scala DataFrame API中,select
方法采用可变数量的参数。在方法签名中,用*
表示,如以下示例所示:
// Greet many people
def greet(who: String*): String = ???
// all valid calls
greet()
greet("world")
greet("alice", "bob")
:
令牌用于向编译器提供有关参数类型的提示,在这种情况下,_*
用于指定我们将集合作为参数列表传递:
def people: Seq[String] = getPeopleToGreet()
greet(people) // won't compile
greet(people: _*) // passes the collection of people as a list of arguments -- works
不确定Python API的工作方式,但是根据我的经验,我想您可以传递单个值或数组,因此我认为问题在Python中根本不存在。