<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to loop over spark dataframe with scala ? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-loop-over-spark-dataframe-with-scala/m-p/28448#M20244</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi - would you mind explaining for me what you'd like the code to do, I'm not sure I understand at the moment. After that I'll happily provide a suggestion as to what it might look like in Spark &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Dec 2018 14:23:53 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-12-12T14:23:53Z</dc:date>
    <item>
      <title>How to loop over spark dataframe with scala ?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-loop-over-spark-dataframe-with-scala/m-p/28447#M20243</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt; Hello ! I 'm rookie to spark scala, here is my problem : tk's in advance for your help&lt;/P&gt;
&lt;P&gt; my input dataframe looks like this :&lt;/P&gt;
&lt;P&gt;index bucket time ap station rssi&lt;/P&gt;&lt;P&gt;&lt;/P&gt; 0 1 00:00 1 1 -84.0&lt;P&gt;&lt;/P&gt; 1 1 00:00 1 3 -67.0&lt;P&gt;&lt;/P&gt; 2 1 00:00 1 4 -82.0&lt;P&gt;&lt;/P&gt; 3 1 00:00 1 2 -68.0&lt;P&gt;&lt;/P&gt; 4 1 00:00 2 5 -68.0&lt;P&gt;&lt;/P&gt; 5 2 00:15 1 3 -83.0&lt;P&gt;&lt;/P&gt; 6 2 00:15 1 2 -82.0&lt;P&gt;&lt;/P&gt; 7 2 00:15 1 4 -80.0&lt;P&gt;&lt;/P&gt; 8 2 00:15 1 1 -72.0&lt;P&gt;&lt;/P&gt; 9 2 00:15 2 5 -72.0&lt;P&gt;&lt;/P&gt; 10 3 00:30 1 4 -85.0&lt;P&gt;&lt;/P&gt; 11 3 00:30 1 3 -77.0&lt;P&gt;&lt;/P&gt; 12 3 00:30 1 2 -70.0&lt;P&gt;&lt;/P&gt; 13 3 00:30 2 5 -70.0
&lt;P&gt; I would like to write an algorithm to do this : &lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; for each ap 
  for each station 
     for each bucket 
        if rssi(previous bucket)&amp;lt;rssi(bucket)
        print message&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt; i don't know how to do this in scala ...&lt;/P&gt;
&lt;P&gt; my start is :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;object coveralg {
    def main(args:Array[String]){
        val spark =SparkSession.builder().appName("coveralg").getOrCreate()
        import spark.implicits._
            val input_data =  spark.read.format("csv").option("header","true").load(args(0))
    }
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;
    but i don't know how to implement a loop over a dataframe and select values to do the if&lt;/P&gt;&lt;P&gt;
    Thank you for your answer&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 11:59:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-loop-over-spark-dataframe-with-scala/m-p/28447#M20243</guid>
      <dc:creator>Pierrek20</dc:creator>
      <dc:date>2018-10-11T11:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop over spark dataframe with scala ?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-loop-over-spark-dataframe-with-scala/m-p/28448#M20244</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi - would you mind explaining for me what you'd like the code to do, I'm not sure I understand at the moment. After that I'll happily provide a suggestion as to what it might look like in Spark &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 14:23:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-loop-over-spark-dataframe-with-scala/m-p/28448#M20244</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-12T14:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop over spark dataframe with scala ?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-loop-over-spark-dataframe-with-scala/m-p/28449#M20245</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Looping is not always necessary, I always use this foreach method, something like the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;aps.collect().foreach(row =&amp;gt; &amp;lt;do something&amp;gt;)&lt;/CODE&gt;&lt;/PRE&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 09:53:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-loop-over-spark-dataframe-with-scala/m-p/28449#M20245</guid>
      <dc:creator>Eve</dc:creator>
      <dc:date>2019-11-19T09:53:57Z</dc:date>
    </item>
  </channel>
</rss>

