PySpark解包元组

时间:2017-03-16 10:54:52

标签: python apache-spark pyspark

我做了一些加入操作,我得到的结果如下:

[(u'20', (u'bbb', 4500)), (u'10', (u'aaa', 3500)), (u'30', (u'ccc', 7500))]

现在我需要将其转换为下方。怎么做

[(u'20', u'bbb', 4500), (u'10', u'aaa', 3500), (u'30', u'ccc', 7500)]

1 个答案:

答案 0 :(得分:0)

[(u'20', u'bbb', 4500), (u'10', u'aaa', 3500), (u'30', u'ccc', 7500)]

结果

    Sub add_new_user()

newUser = ActiveWorkbook.Sheets("Admin").newUserTextBox.Value

struserdn = GetUserFullName(newUser)

If struserdn <> "Error" Then

    answer = MsgBox("Do you want to add the following user?" & vbNewLine & vbNewLine & struserdn & vbNewLine & newUser & "@abcd.com", vbYesNo + vbQuestion, "New User")
    If answer = vbYes Then
        Dim newUSheet As Worksheet
        Worksheets("Example_sheet").Copy Before:=Worksheets("Example_sheet")
        Set newUSheet = ActiveSheet
        newUSheet.Name = newUser
        newUSheet.Unprotect "123" 

        'need some code here to allow the newUser to edit ranges A4:F10000

        newUSheet.protect "123"
        newUSheet.Rows("A1").Value = struserdn

    Else
        Exit Sub
    End If
Else
    MsgBox "User name not found!", , "Error"
    Exit Sub
End If

End Sub