title: Python Pandas problem while assigning a value to a column cell using either "loc" or "at method inside loop
body: <p>I have a data-frame (df) with the following columns:</p>
  <pre><code>source           company category                                             header                                            content published_date  sentiment
  0  Forbes  General Electric     None  Is New England Baking The Books On Oil-Fired C...  The rise of natural gas as the primary fuel fo...     2014-01-01          0
  1  Forbes  General Electric     None  DARPA Is Building A Vanishing Battery: This Po...  Considering that batteries are typically desig...     2014-01-02          0
  2  Forbes  General Electric     None      Four High-Yielding ETFs For Growth And Income  Growth &amp; income exchange-traded funds typicall...     2014-01-02          0
  3  Forbes         Citigroup     None                      Analyst Moves: BAC, DUK, PZZA  This morning, Citigroup upgraded shares of Ban...     2014-01-02          0
  4     WSJ          JPMorgan  MARKETS  JPMorgan Broker Barred for Role in Insider Tra...  Finra says information about merger, acquisiti...     2014-01-02          0
  </code></pre>
  <p>The expected result that I should get, after assigning the new valus to the column <code>sentiment</code>, is the following (over 23,000 rows in total):</p>
  <pre><code>    source           company category                                             header                                            content published_date  sentiment
  0  Forbes  General Electric     None  Is New England Baking The Books On Oil-Fired C...  The rise of natural gas as the primary fuel fo...     2014-01-01          -1
  1  Forbes  General Electric     None  DARPA Is Building A Vanishing Battery: This Po...  Considering that batteries are typically desig...     2014-01-02          1
  2  Forbes  General Electric     None      Four High-Yielding ETFs For Growth And Income  Growth &amp; income exchange-traded funds typicall...     2014-01-02          0
  3  Forbes         Citigroup     None                      Analyst Moves: BAC, DUK, PZZA  This morning, Citigroup upgraded shares of Ban...     2014-01-02          -1
  4     WSJ          JPMorgan  MARKETS  JPMorgan Broker Barred for Role in Insider Tra...  Finra says information about merger, acquisiti...     2014-01-02          1
  </code></pre>
  <p>The algorithm that I'm using in order to update the <code>sentiment</code> column cell values is the shown below.
  Note: I verified the updated values before and after using 'at' o 'loc' inside the loop ' for e in ch_ix:'. The cell values do change, but only inside that loop.
  If I try to verify by printing 'dfd['sentiment]' the resulting values are still the same 0s:</p>
  <pre><code>    dfd = db_data.copy()
      for index in range(len(stock_list_company_name)):
        cont = dfd.loc[dfd[&quot;company&quot;] == stock_list_company_name[index]]
  
        #stock_data is another df which contains the columns 'ticker, date, closed, volume, sentiment' and has more rows than dfd.
        cont2 = stock_data.loc[stock_data[&quot;ticker&quot;] == ticker_list[index]]
        dates = cont2[&quot;date&quot;].values
        for ix in range(len(dates)):
          if(not cont.loc[cont[&quot;published_date&quot;] == dates[ix]].empty):
            ch_ix = cont.loc[cont[&quot;published_date&quot;] == dates[ix], &quot;sentiment&quot;].index
            for e in ch_ix:
             cont.at[e,&quot;sentiment&quot;] = cont2[&quot;sentiment&quot;].values[ix]
      print(dfd['sentiment'] #values are still 0s
  </code></pre>
  <p>Can someone please help me if this is a loop lack of memory or chained indexing problem? I can't still figure out why the values are not being updated.
  <strong>Testing and running the code in this Google Colab =&gt; <a href="https://colab.research.google.com/drive/11D3WFzUWYioNg2XvYpKfpW9lLzI4zlQE?usp=sharing" rel="nofollow noreferrer">url</a></strong></p>