title: How to use a boolean to rename and replace values in a column?
body: <p>I am working with a dataframe, and a few data columns have missing catagories represented by a <code>'?'</code> in a column. I am trying to use a boolean to rename and replace the missing catagories marked <code>'?'</code> with <code>'Private'</code>in a column labled <code>workclass</code>. The data is read in as:</p>
  
  <pre><code>import numpy as np 
  import pandas as pd
  import matplotlib.pyplot as plt
  from pandas.plotting import scatter_matrix
  from sklearn.preprocessing import *
  url2="https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data" #Reading in Data from a freely and easily available source on the internet
  Adult = pd.read_csv(url2, header=None)
  ##Assigning column names to the dataframe
  Adult.columns = ["age","workclass","fnlwgt","education","educationnum","maritalstatus","occupation",  
                   "relationship","race","sex","capitalgain","capitalloss","hoursperweek","nativecountry",
                   "less50kmoreeq50kn"]
  </code></pre>
  
  <p>I have tried running the code:</p>
  
  <pre><code>MissingValue = Adult.loc[:, "workclass"] == "?"
  Adult.loc[MissingValue, "workclass"] = "Private"
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Adult.loc[ Adult.loc[:, "workclass"] == "?", "workclass"] = "Private"
  </code></pre>
  
  <p>I do not get any error's when running the code however when checking the column values with <code>(Adult.loc[:,'workclass'].value_counts())</code> the <code>'?'</code> is still there.
  The code: <code>Adult['workclass'] = Adult['workclass'].str.replace('?', 'Private')</code> works for what I want to accomplish however I would like to be able to do it with a boolean. Any suggestions on why this might be happening?</p>