title: Pandas Error can only use .str accessor with string
body: <p>This is my code,</p>
  
  <pre><code>import pandas as pd
  import os
  
  os.chdir('path\to\input\file')
  
  xl_file = pd.ExcelFile('newcustomers.xlsx')
  df = xl_file.parse('Customers Export 1', index_col='Domain', na_values=['NA'])
  
  df = df[(df["Customer phone"].str.startswith("+1")) &amp; (df["Customer phone"].str.len() == 13)]
  
  print
  print "now changing to final CSV output directory"
  print
  
  os.chdir('path\to\output\directory')
  
  print "Current working dir : %s" % os.getcwd()
  
  df.to_csv('newcustomers.csv')
  </code></pre>
  
  <p>Basically the column has phone numbers, and I am using this to remove incomplete numbers/blank entries, and phone numbers that don't start with +1. (the US/CA country dial code). It worked great for a week, but then I started getting this error. And I have not updated python or pandas in between. </p>
  
  <pre><code>raise AttributeError("Can only use .str accessor with string "
  AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandas
  </code></pre>
  
  <p>I am using anaconda on windows 8.1 the versions are as follows:</p>
  
  <pre><code>conda update conda
      conda 3.18.8 py27_0 defaults
  conda update anaconda
      anaconda 2.4.0 np110py27_0 &lt;unknown&gt;
  conda update pandas
      pandas 0.17.1 np110py27_0 defaults
  </code></pre>
  
  <p>Nothing has changed between all last week up to Sunday when the code worked, then yesterday without any updates, or changes to the input file or anything it starts getting mad at me :/ </p>
  
  <p>EDIT:
  Adding df.head(2) per @WoodChopper request</p>
  
  <pre><code>Domain        Customer Name    Customer phone
  example.com   John Doe         44.xxxxxx
  google.com    Jane Doe         1.xxxxxx
  </code></pre>
  
  <p>In the original XLSX file that it is opening it does list the entire phone number with the '+' sign. But that is all that returns to CMD when I use: </p>
  
  <pre><code>print df.head(2)
  </code></pre>
  
  <p>And that is just doing the xl_file variable, the df variable, and then print the above statement. I am blocking out with # the</p>
  
  <pre><code>df = df[(df["Registrant phone"].str.startswith("+1")) &amp; (df["Registrant phone"].str.len() == 13)]
  </code></pre>
  
  <p>EDIT x2</p>
  
  <p>Just to clarify, this is the code as of now</p>
  
  <pre><code>import pandas as pd
  import os
  
  os.chdir('path\to\input\file')
  
  df = pd.read_excel('newcustomers.xlsx', sheetname = 'Customers Export 1')
  
  #xl_file = pd.ExcelFile('newcustomers.xlsx')
  #df = xl_file.parse('Customers Export 1', index_col='Domain', na_values=['NA'], convert_float=False)
  #df.drop(df.columns[[0]], axis=1, inplace=True)
  
  #print df.head(2)
  #print (df["Registrant phone"])
  df = df[(df["Registrant phone"].str.startswith("+1")) &amp; (df["Registrant phone"].str.len() == 13)]
  
  print
  print "now changing to final CSV output directory"
  print
  
  os.chdir('path\to\output\directory')
  
  print "Current working dir : %s" % os.getcwd()
  
  df.to_csv('newcustomers.csv')
  </code></pre>
  
  <p>Still returns all the same results. Just to make sure we're not chasing down the wrong rabbit, <a href="http://i.imgur.com/qa5ldOK.png" rel="nofollow">Here is the exact error</a>(imgur).</p>
  
  <p>Could this be something outside the code? Pandas, conda, and anaconda are up to date. Is there another library that Pandas is dependent on that could have gone out of date (which wouldn't entirely make sense since everything worked one day and the next it didn't)? </p>