<?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 ApplyInPandas failing at a particular grouped item in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/applyinpandas-failing-at-a-particular-grouped-item/m-p/63707#M3113</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a code that performs a forecast for 21k items in parallel. It looks like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt; def forward_forecast(data):
    model = ETSModel(window_data, error='add', trend='add', seasonal=None)
                fitted_model = model.fit(disp=0)
                # Forecast the missing value
                forecast = fitted_model.forecast(steps=1).values[0]
                # Replace the missing value with the forecasted value
                data.loc[start_index:end_index-1, 'y_hat'] = forecast
                return data
result = data.groupBy("item").applyInPandas(foreward_forecast,schema)&lt;/LI-CODE&gt;&lt;P&gt;When I run this code with a couple of items it run fine, but when I try using the 21k items, it fails at one item and gives this error: "&lt;SPAN&gt;unsupported operand type(s) for -: 'NoneType' and 'int'"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I am trying to figure out how to troubleshoot it and find&amp;nbsp; out at which item my function is failing.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 14 Mar 2024 15:15:12 GMT</pubDate>
    <dc:creator>mbejarano89</dc:creator>
    <dc:date>2024-03-14T15:15:12Z</dc:date>
    <item>
      <title>ApplyInPandas failing at a particular grouped item</title>
      <link>https://community.databricks.com/t5/machine-learning/applyinpandas-failing-at-a-particular-grouped-item/m-p/63707#M3113</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a code that performs a forecast for 21k items in parallel. It looks like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt; def forward_forecast(data):
    model = ETSModel(window_data, error='add', trend='add', seasonal=None)
                fitted_model = model.fit(disp=0)
                # Forecast the missing value
                forecast = fitted_model.forecast(steps=1).values[0]
                # Replace the missing value with the forecasted value
                data.loc[start_index:end_index-1, 'y_hat'] = forecast
                return data
result = data.groupBy("item").applyInPandas(foreward_forecast,schema)&lt;/LI-CODE&gt;&lt;P&gt;When I run this code with a couple of items it run fine, but when I try using the 21k items, it fails at one item and gives this error: "&lt;SPAN&gt;unsupported operand type(s) for -: 'NoneType' and 'int'"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I am trying to figure out how to troubleshoot it and find&amp;nbsp; out at which item my function is failing.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 15:15:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/applyinpandas-failing-at-a-particular-grouped-item/m-p/63707#M3113</guid>
      <dc:creator>mbejarano89</dc:creator>
      <dc:date>2024-03-14T15:15:12Z</dc:date>
    </item>
  </channel>
</rss>

