2016-07-10 1 views
0

나는 mooc을 복용하고 있습니다.pyspark.sql 구문과 함수의 차이를 이해하고 폭발 및 균열

는 그것은 텍스트

word            | 
+-------------------------------------------------+ 
|1609            | 
|             | 
|the sonnets          | 
|             | 
|by william shakespeare       | 
|             | 
|             | 
|             | 
|1            | 
|from fairest creatures we desire increase  | 
|that thereby beautys rose might never die  | 
|but as the riper should by time decease   | 
|his tender heir might bear his memory   | 
|but thou contracted to thine own bright eyes  | 
|feedst thy lights flame with selfsubstantial fuel| 
+-------------------------------------------------+ 

아래에있는 shakespeareDF의 dataframe을 가지고, 그들은 코드

from pyspark.sql.functions import split, explode 
shakeWordsDF = (shakespeareDF.select(explode(split(shakespeareDF[0],"\s+")) 

아래 실행 이해하고 싶습니다 :

  1. 의 차이 무엇인가 폭발하고 분할 왜 우리는 둘 다 사용해야합니까? 나는 온라인 문서로보고 노력하고 이유는

답변

0

Q.1 이 here

Q.2 을 보면 우리가 shakespeareDF [0]뿐 아니라 shakespeareDF를 사용해야 할

  • 을 이해 couldnt한다 shakespeareDF [0] - 첫 번째 열을 선택

  • +0

    shakespeareDF가 1 열 밖에 없다면 shakespeareDF [0]을 사용해야합니까? – user2543622

    +0

    shakespeareDF는 Dataframe ..이며 필요한 것은 컬럼입니다. 컬럼 이름 shakespeareDF [ 'Column_Name']을 명시 적으로 지정하여 해당 컬럼을 선택할 수 있습니다. 또는이 경우 첫 번째 (및 유일한) 열이기 때문에 열 인덱스 .. 0을 사용하십시오. –