我已经编写了此函数:
def test = udf(() => List[Map[String, String]] {
def a = Map("A" -> "A")
def b = Map("B" -> "B")
List(a, b)
})
然后出现以下错误:
找到的:需要列表[scala.collection.immutable.Map [String,String]]:Map [String,String] 列出(a,b)
我在做什么错了?
答案 0 :(得分:0)
尝试
def test = udf(() => {
def a = Map("A" -> "A")
def b = Map("B" -> "B")
List[Map[String, String]](a, b)
})
aka
>>> import pandas as pd
>>> df = pd.DataFrame({'a':[1,2,3], 'b':[4,5,6]})
>>> df2 = df.drop('b', axis=1, inplace=False)
>>> df2
a
0 1
1 2
2 3
>>> df
a b
0 1 4
1 2 5
2 3 6