<?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 How to add Columns for Automatic Fill on Pandas Python in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-add-columns-for-automatic-fill-on-pandas-python/m-p/13233#M7946</link>
    <description>&lt;P&gt;1. I have data x,I would like to create a new column with the condition that the value are 1, 2 or 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. The name of the column is SHIFT where this SHIFT column will be filled automatically if the TIME_CREATED column meets the conditions.&lt;/P&gt;&lt;P&gt;3. the condition are :&lt;/P&gt;&lt;P&gt;# 00:00:00 - 07.59.59 = Shift 1&lt;/P&gt;&lt;P&gt;# 08:00:00 - 15:59:59 = Shift 2&lt;/P&gt;&lt;P&gt;# 16:00:00 - 23:59:59 = Shift 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. on the above conditions apply only to Time as hours:minutes:seconds&lt;/P&gt;&lt;P&gt;5. I attach the link of the py and ipynb files for test and study&lt;/P&gt;&lt;P&gt;6. I've tried the test only for the selection using a query but it's still stuck and it only shows up for 1 day.&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/drive/folders/1xdDwNfbDNzYb2SfJ_h-DurY_KXFAj9rl?usp=sharing" target="test_blank"&gt;https://drive.google.com/drive/folders/1xdDwNfbDNzYb2SfJ_h-DurY_KXFAj9rl?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Columns Table"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2399i7C9EF3A51EF7A935/image-size/large?v=v2&amp;amp;px=999" role="button" title="Columns Table" alt="Columns Table" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Result of tested"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2393i88F6B8D35712B168/image-size/large?v=v2&amp;amp;px=999" role="button" title="Result of tested" alt="Result of tested" /&gt;&lt;/span&gt;Thanks,&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 11:48:38 GMT</pubDate>
    <dc:creator>omsas</dc:creator>
    <dc:date>2021-10-15T11:48:38Z</dc:date>
    <item>
      <title>How to add Columns for Automatic Fill on Pandas Python</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-columns-for-automatic-fill-on-pandas-python/m-p/13233#M7946</link>
      <description>&lt;P&gt;1. I have data x,I would like to create a new column with the condition that the value are 1, 2 or 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. The name of the column is SHIFT where this SHIFT column will be filled automatically if the TIME_CREATED column meets the conditions.&lt;/P&gt;&lt;P&gt;3. the condition are :&lt;/P&gt;&lt;P&gt;# 00:00:00 - 07.59.59 = Shift 1&lt;/P&gt;&lt;P&gt;# 08:00:00 - 15:59:59 = Shift 2&lt;/P&gt;&lt;P&gt;# 16:00:00 - 23:59:59 = Shift 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. on the above conditions apply only to Time as hours:minutes:seconds&lt;/P&gt;&lt;P&gt;5. I attach the link of the py and ipynb files for test and study&lt;/P&gt;&lt;P&gt;6. I've tried the test only for the selection using a query but it's still stuck and it only shows up for 1 day.&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/drive/folders/1xdDwNfbDNzYb2SfJ_h-DurY_KXFAj9rl?usp=sharing" target="test_blank"&gt;https://drive.google.com/drive/folders/1xdDwNfbDNzYb2SfJ_h-DurY_KXFAj9rl?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Columns Table"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2399i7C9EF3A51EF7A935/image-size/large?v=v2&amp;amp;px=999" role="button" title="Columns Table" alt="Columns Table" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Result of tested"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2393i88F6B8D35712B168/image-size/large?v=v2&amp;amp;px=999" role="button" title="Result of tested" alt="Result of tested" /&gt;&lt;/span&gt;Thanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 11:48:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-columns-for-automatic-fill-on-pandas-python/m-p/13233#M7946</guid>
      <dc:creator>omsas</dc:creator>
      <dc:date>2021-10-15T11:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to add Columns for Automatic Fill on Pandas Python</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-columns-for-automatic-fill-on-pandas-python/m-p/13234#M7947</link>
      <description>&lt;P&gt;seems like a simple case statement, or elif in python, no?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 13:00:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-columns-for-automatic-fill-on-pandas-python/m-p/13234#M7947</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2021-10-15T13:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to add Columns for Automatic Fill on Pandas Python</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-columns-for-automatic-fill-on-pandas-python/m-p/13235#M7948</link>
      <description>&lt;P&gt;You an do something like this in pandas. Note there could be a more performant way to do this too. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import pandas as pd
import numpy as np
&amp;nbsp;
df = pd.DataFrame({'a':[1,2,3,4]})
df.head()
&amp;gt;      a
&amp;gt; 0  1
&amp;gt; 1  2
&amp;gt; 2  3
&amp;gt; 3  4
&amp;nbsp;
conditions = [(df['a'] &amp;lt;=2), (df['a']&amp;gt;2)]
values = ['value1', 'value2']
&amp;nbsp;
&amp;nbsp;
df['b'] = np.select(conditions, values)
&amp;nbsp;
df.head()
         a       b
&amp;gt; 0  1  value1
&amp;gt; 1  2  value1
&amp;gt; 2  3  value2
&amp;gt; 3  4  value2&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 19:59:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-columns-for-automatic-fill-on-pandas-python/m-p/13235#M7948</guid>
      <dc:creator>Ryan_Chynoweth</dc:creator>
      <dc:date>2021-10-15T19:59:20Z</dc:date>
    </item>
  </channel>
</rss>

