title: PYTHON: Appending converted continuous attributes (converted to categorical) to the original dataset using pandas library
body: <p>I am new to python and I want to implement Naive Bayes Classifier using the pandas library. For this i want to convert all the continuous attributes to categorical and vice versa. </p>
  
  <p>I am using the first strategy and i am trying to convert the continuous attributes to the categorical attributes so that there is consistency of data. The dataset I am using is the Income dataset available at : <a href="http://archive.ics.uci.edu/ml/datasets/Adult" rel="nofollow">http://archive.ics.uci.edu/ml/datasets/Adult</a></p>
  
  <p>Now I converted the continuous attributes to categorical using </p>
  
  <pre><code>pandas.cut(X, bins, labels = None)
  </code></pre>
  
  <p>method. I used the equal width binning method to assign labels to certain bin widths.(example below). I stored it in a variable cat_age. Now I want to replace the age attribute in dataset with the categorical age attribute.</p>
  
  <pre><code>cat_age = pd.cut(age, [0, 25, 45, 65, 95], labels = ["Young", "Middle-aged", "Senior", "Old"], right = True , include_lowest = True)
  </code></pre>
  
  <p>But i am unable to replace the OLD age attribute values in the dataset. I tried using DataFrame.replace() and DataFrame.assign() methods.</p>
  
  <pre><code>pandas.DataFrame.replace(to_replace='AGE', value = cat_age)   #AGE is the column name in the dataset.
  </code></pre>
  
  <p>and </p>
  
  <pre><code>pandas.DataFrame.assign(AGE = cat_age)
  </code></pre>
  
  <p>but it is not letting me replace or assign different values to the column in the dataset.</p>
  
  <pre><code>The DataFrame.replace() method doesn't give any error but doesn't show the new values in the dataset either.
  </code></pre>
  
  <p>I am sure I am doing some Naive mistake. Can anyone suggest me a way that I am able to either append a new AGE column with categorical values or replace the old column with these new values. </p>
  
  <pre><code>old values are of type : int64 while new values are of type : str
  </code></pre>
  
  <p>This is just 1 column, there are other values in the dataset which i want to convert to categorical:hours-per-week, capital-gain, capital-loss. Any help would be greatly appreciated.</p>