databricks.koalas.DataFrame.spark.schema¶
-
spark.
schema
(index_col: Union[str, List[str], None] = None) → pyspark.sql.types.StructType¶ Returns the underlying Spark schema.
- Parameters
- index_col: str or list of str, optional, default: None
Column names to be used in Spark to represent Koalas’ index. The index name in Koalas is ignored. By default, the index is always lost.
- Returns
- pyspark.sql.types.StructType
The underlying Spark schema.
Examples
>>> df = ks.DataFrame({'a': list('abc'), ... 'b': list(range(1, 4)), ... 'c': np.arange(3, 6).astype('i1'), ... 'd': np.arange(4.0, 7.0, dtype='float64'), ... 'e': [True, False, True], ... 'f': pd.date_range('20130101', periods=3)}, ... columns=['a', 'b', 'c', 'd', 'e', 'f']) >>> df.spark.schema().simpleString() 'struct<a:string,b:bigint,c:tinyint,d:double,e:boolean,f:timestamp>' >>> df.spark.schema(index_col='index').simpleString() 'struct<index:bigint,a:string,b:bigint,c:tinyint,d:double,e:boolean,f:timestamp>'