title: Pickling error on pyspark fit object
body: <p>I get the following error in the code below. It would be great if someone can help me understand what the error is and how can it be bypassed</p>
  
  <pre><code>charcols = [item[0] for item in training_data.dtypes if item[1].endswith('string')]
  Indexer = StringIndexer(inputCol = charcols[0], outputCol=charcols[0]+ "indexed", handleInvalid="skip")
  indexer_fit = Indexer.fit(training_data)
  training_data = indexer_fit.transform(training_data)
  dmp = pickle.dumps(indexer_fit)
  
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/hdp/current/spark2-client/python/lib/py4j-0.10.4-src.zip/py4j/java_gateway.py", line 1133, in __call__
    File "/usr/hdp/current/spark2-client/python/pyspark/sql/utils.py", line 63, in deco
      return f(*a, **kw)
  File "/usr/hdp/current/spark2-client/python/lib/py4j-0.10.4-src.zip/py4j/protocol.py", line 323, in get_return_value
  py4j.protocol.Py4JError: An error occurred while calling o59.__getstate__. Trace:
  py4j.Py4JException: Method __getstate__([]) does not exist
          at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
          at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
          at py4j.Gateway.invoke(Gateway.java:272)
          at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
          at py4j.commands.CallCommand.execute(CallCommand.java:79)
          at py4j.GatewayConnection.run(GatewayConnection.java:214)
          at java.lang.Thread.run(Thread.java:748)
  </code></pre>