Skip to content

Commit ea1897d

Browse files
committed
For implicit name of pandas.columns are Int, so should be convert to String.
1 parent 5452457 commit ea1897d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python/pyspark/sql/context.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,15 @@ def createDataFrame(self, data, schema=None, samplingRatio=None):
342342
343343
>>> sqlContext.createDataFrame(df.toPandas()).collect() # doctest: +SKIP
344344
[Row(name=u'Alice', age=1)]
345+
>>> sqlContext.createDataFrame(pandas.DataFrame([[1, 2]]).collect())
346+
[Row(0=1, 1=2)]
345347
"""
346348
if isinstance(data, DataFrame):
347349
raise TypeError("data is already a DataFrame")
348350

349351
if has_pandas and isinstance(data, pandas.DataFrame):
350352
if schema is None:
351-
schema = list(data.columns)
353+
schema = [str(x) for x in data.columns]
352354
data = [r.tolist() for r in data.to_records(index=False)]
353355

354356
if not isinstance(data, RDD):

0 commit comments

Comments
 (0)