Ben Chuanlong Du's Blog

It is never too late to learn.

Spark Issue: TypeError WithReplacement

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Symptoms

TypeError: withReplacement (optional), fraction (required) and seed (optional) should be a bool, float and number; however, got [].

Causes

An integer number (e.g., 1) is passed to the fraction parameter of the function DataFrame.sample in PySpark.

Solutions

Use a float number (e.g., 1.0) instead.

Comments