Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

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 [<class ‘int’>].

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.