title: Unclear on TypeError message from Google NL API running sentiment analysis
body: <p><strong>Goal</strong></p>
  <p>To run sentiment analysis on a column of text in a pandas dataframe, having it return both score and magnitude values for each line of text.</p>
  <p><strong>Current code</strong></p>
  <p>This is what I'm running, pulling in a dataframe (<code>df03</code>) with a column of text (<code>text02</code>) that I want to analyze.</p>
  <pre><code># Imports the Google Cloud client library
  from google.cloud import language_v1
  
  # Instantiates a client
  client = language_v1.LanguageServiceClient()
  
  # The text to analyze
  text = df03.loc[:,&quot;text02&quot;]
  document = language_v1.Document(
      content=text, type_=language_v1.types.Document.Type.PLAIN_TEXT
  )
  
  # Detects the sentiment of the text
  sentiment = client.analyze_sentiment(
      request={&quot;document&quot;: document}
  ).document_sentiment
  
  print(&quot;Text: {}&quot;.format(text))
  print(&quot;Sentiment: {}, {}&quot;.format(sentiment.score, sentiment.magnitude))
  </code></pre>
  <p>And this is the returned error message</p>
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-7-1c6f7c607084&gt; in &lt;module&gt;()
        8 text = df03.loc[:,&quot;text02&quot;]
        9 document = language_v1.Document(
  ---&gt; 10     content=text, type_=language_v1.types.Document.Type.PLAIN_TEXT
       11 )
       12 
  
  /usr/local/lib/python3.7/dist-packages/proto/message.py in __init__(self, mapping, ignore_unknown_fields, **kwargs)
      562 
      563         # Create the internal protocol buffer.
  --&gt; 564         super().__setattr__(&quot;_pb&quot;, self._meta.pb(**params))
      565 
      566     def _get_pb_type_from_key(self, key):
  
  TypeError: 01                          Max Muncy is great!
  02               The worst Dodger is Max muncy.
  03   has type Series, but expected one of: bytes, unicode
  </code></pre>
  <p><strong>Assessment</strong></p>
  <p>The error message points to the line:</p>
  <p><code>content=text, type_=language_v1.types.Document.Type.PLAIN_TEXT</code></p>
  <p>The <code>TypeError</code> message attempts to explain what's happening:</p>
  <p><code>has type Series, but expected one of: bytes, unicode</code></p>
  <p>So it seems to recognize the list of text blurbs under the <code>text</code> column in dataframe <code>df03</code>, but apparently I failed to establish the right data type setting.</p>
  <p>However, I'm not sure where I'm supposed to set the Type, as the only Document Type settings in the documentation appear to be HTML, PLAIN_TEXT, or TYPE_UNSPECIFIED. Of those, I'm pretty sure <code>PLAIN_TEXT</code> is right.</p>
  <p><strong>Documentation:</strong>
  <a href="https://googleapis.dev/python/language/latest/language_v1/types.html#google.cloud.language_v1.types.Document" rel="nofollow noreferrer">https://googleapis.dev/python/language/latest/language_v1/types.html#google.cloud.language_v1.types.Document</a></p>
  <p>So that leaves me unclear on what that error message is indicating or how I should approach troubleshooting.</p>
  <p>Greatly appreciate any input on this.</p>
  <p>doug</p>