def _inferSchema(self, rdd, samplingRatio=None):
    '\n        Infer schema from an RDD of Row or tuple.\n\n        :param rdd: an RDD of Row or tuple\n        :param samplingRatio: sampling ratio, or no sampling (default)\n        :return: :class:`pyspark.sql.types.StructType`\n        '
    first = rdd.first()
    if (not first):
        raise ValueError('The first row in RDD is empty, can not infer schema')
    if (type(first) is dict):
        warnings.warn('Using RDD of dict to inferSchema is deprecated. Use pyspark.sql.Row instead')
    if (samplingRatio is None):
        schema = _infer_schema(first)
        if _has_nulltype(schema):
            for row in rdd.take(100)[1:]:
                schema = _merge_type(schema, _infer_schema(row))
                if (not _has_nulltype(schema)):
                    break
            else:
                raise ValueError('Some of types cannot be determined by the first 100 rows, please try again with sampling')
    else:
        if (samplingRatio < 0.99):
            rdd = rdd.sample(False, float(samplingRatio))
        schema = rdd.map(_infer_schema).reduce(_merge_type)
    return schema
Infer schema from an RDD of Row or tuple.

:param rdd: an RDD of Row or tuple
:param samplingRatio: sampling ratio, or no sampling (default)
:return: :class:`pyspark.sql.types.StructType`
def _inferSchema(self, rdd, samplingRatio=None):
    '\n        Infer schema from an RDD of Row or tuple.\n\n        :param rdd: an RDD of Row or tuple\n        :param samplingRatio: sampling ratio, or no sampling (default)\n        :return: :class:`pyspark.sql.types.StructType`\n        '
    first = rdd.first()
    if (not first):
        raise ValueError('The first row in RDD is empty, can not infer schema')
    if (type(first) is dict):
        warnings.warn('Using RDD of dict to inferSchema is deprecated. Use pyspark.sql.Row instead')
    if (samplingRatio is None):
        schema = _infer_schema(first)
        if _has_nulltype(schema):
            for row in rdd.take(100)[1:]:
                schema = _merge_type(schema, _infer_schema(row))
                if (not _has_nulltype(schema)):
                    break
            else:
                raise ValueError('Some of types cannot be determined by the first 100 rows, please try again with sampling')
    else:
        if (samplingRatio < 0.99):
            rdd = rdd.sample(False, float(samplingRatio))
        schema = rdd.map(_infer_schema).reduce(_merge_type)
    return schema