def _createFromRDD(self, rdd, schema, samplingRatio):
        """
        Create an RDD for DataFrame from an existing RDD, returns the RDD and schema.
        """
        if schema is None or isinstance(schema, (list, tuple)):
            struct = self._inferSchema(rdd, samplingRatio, names=schema)
            converter = _create_converter(struct)
            rdd = rdd.map(converter)
            if isinstance(schema, (list, tuple)):
                for i, name in enumerate(schema):
                    struct.fields[i].name = name
                    struct.names[i] = name
            schema = struct

        elif not isinstance(schema, StructType):
            raise TypeError("schema should be StructType or list or None, but got: %s" % schema)

        # convert python objects to sql data
        rdd = rdd.map(schema.toInternal)
        return rdd, schema
def _createFromRDD ( self , rdd , schema , samplingRatio ) : if schema is None or isinstance ( schema , ( list , tuple ) ) : struct = self . _inferSchema ( rdd , samplingRatio , names = schema ) converter = _create_converter ( struct ) rdd = rdd . map ( converter ) if isinstance ( schema , ( list , tuple ) ) : for i , name in enumerate ( schema ) : struct . fields [ i ] . name = name struct . names [ i ] = name schema = struct elif not isinstance ( schema , StructType ) : raise TypeError ( "schema should be StructType or list or None, but got: %s" % schema ) rdd = rdd . map ( schema . toInternal ) return rdd , schema
Create an RDD for DataFrame from an existing RDD, returns the RDD and schema.