在 Databricks / Spark DataFrame 对象中执行代码时收到错误不支持项目分配
Receiving error when executitng code in Databricks / Spark DataFrame' object does not support item assignment
当运行以下命令时我得到错误
我是运行Databricks Platform上的代码,但是代码是用Pandas
写的
类型错误:'DataFrame'对象不支持项目分配
如果错误与不支持代码的 spark/databricks 平台有关,有人可以告诉我吗?
import numpy as np
import pandas as pd
def matchSchema(df):
df['active'] = df['active'].astype('boolean')
df['price'] = df['counts']/100
df.drop('counts', axis=1, inplace=True)
return df,df.head(3)
(dataset, sample) = matchSchema(df)
print(dataset)
print(sample)
错误是:
类型错误:'DataFrame'对象不支持项目分配
使用 bool 而不是 boolean 作为 dtype...
df['active'] = df['active'].astype('bool')
当运行以下命令时我得到错误
我是运行Databricks Platform上的代码,但是代码是用Pandas
写的类型错误:'DataFrame'对象不支持项目分配
如果错误与不支持代码的 spark/databricks 平台有关,有人可以告诉我吗?
import numpy as np
import pandas as pd
def matchSchema(df):
df['active'] = df['active'].astype('boolean')
df['price'] = df['counts']/100
df.drop('counts', axis=1, inplace=True)
return df,df.head(3)
(dataset, sample) = matchSchema(df)
print(dataset)
print(sample)
错误是:
类型错误:'DataFrame'对象不支持项目分配
使用 bool 而不是 boolean 作为 dtype...
df['active'] = df['active'].astype('bool')