<?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>question Re: Iterate a dataframe in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Iterate-a-dataframe/m-p/137338#M31815</link>
    <description>&lt;PRE&gt;iterate = df.map(lambda p: "Name: " + p.blglast )
for iteration in iterate.collect():
  print(iteration)
&lt;/PRE&gt;&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/6006/nanyimalain.html" nodeid="6006"&gt;@alain TSAFACK&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Please refer : &lt;A href="http://spark.apache.org/docs/latest/sql-programming-guide.html" target="_blank"&gt;http://spark.apache.org/docs/latest/sql-programming-guide.html&lt;/A&gt; for more information &lt;/P&gt;</description>
    <pubDate>Tue, 14 Jun 2016 18:11:27 GMT</pubDate>
    <dc:creator>sandyy006</dc:creator>
    <dc:date>2016-06-14T18:11:27Z</dc:date>
    <item>
      <title>Iterate a dataframe</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Iterate-a-dataframe/m-p/137336#M31813</link>
      <description>&lt;P&gt;Hello,
Please I will like to iterate and perform calculations accumulated in a column of my dataframe but I can not. Can you help me?
Thank you&lt;/P&gt;&lt;P&gt;Here the creation of my dataframe. I would like to calculate an accumulated blglast the column and stored in a new column&lt;/P&gt;&lt;P&gt;from pyspark.sql import HiveContext
from pyspark import SparkContext
from pandas import DataFrame as df

sc =SparkContext()

hive_context = HiveContext(sc)
tab = hive_context.table("table")

tab.registerTempTable("tab_temp")

df=hive_context.sql("SELECT  blglast FROM tab_temp AS b limit 50")&lt;/P&gt;&lt;P&gt;df.show()&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 15:43:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Iterate-a-dataframe/m-p/137336#M31813</guid>
      <dc:creator>nanyim_alain</dc:creator>
      <dc:date>2016-06-14T15:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate a dataframe</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Iterate-a-dataframe/m-p/137337#M31814</link>
      <description>&lt;P&gt;after df=hive_context.sql("SELECT blglast FROM tab_temp AS b limit 50"), you can get the row object in which you can perform your custom logic.&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; for row in df.rdd.collect():&lt;/P&gt;&lt;P&gt;
...     dosomething ...&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 16:10:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Iterate-a-dataframe/m-p/137337#M31814</guid>
      <dc:creator>rajkumar_singh</dc:creator>
      <dc:date>2016-06-14T16:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate a dataframe</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Iterate-a-dataframe/m-p/137338#M31815</link>
      <description>&lt;PRE&gt;iterate = df.map(lambda p: "Name: " + p.blglast )
for iteration in iterate.collect():
  print(iteration)
&lt;/PRE&gt;&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/6006/nanyimalain.html" nodeid="6006"&gt;@alain TSAFACK&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Please refer : &lt;A href="http://spark.apache.org/docs/latest/sql-programming-guide.html" target="_blank"&gt;http://spark.apache.org/docs/latest/sql-programming-guide.html&lt;/A&gt; for more information &lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 18:11:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Iterate-a-dataframe/m-p/137338#M31815</guid>
      <dc:creator>sandyy006</dc:creator>
      <dc:date>2016-06-14T18:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate a dataframe</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Iterate-a-dataframe/m-p/137339#M31816</link>
      <description>&lt;P&gt;Hello,
Thank you for the directive. But I 'm new to the dataframe and what I try to do is be able to make it to retrieve the values of the indices i and i + 1 for example.
Best regards&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 15:30:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Iterate-a-dataframe/m-p/137339#M31816</guid>
      <dc:creator>nanyim_alain</dc:creator>
      <dc:date>2016-06-21T15:30:05Z</dc:date>
    </item>
  </channel>
</rss>

