Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何确定数据帧是Pandas还是Spark?_Pandas_Apache Spark_Dataframe - Fatal编程技术网

如何确定数据帧是Pandas还是Spark?

如何确定数据帧是Pandas还是Spark?,pandas,apache-spark,dataframe,Pandas,Apache Spark,Dataframe,我将数据帧传递给函数。有时是熊猫数据帧,有时是火花数据帧。我的职能部门需要采取相应行动。是否有一种简单的方法,例如df.isPandas(),来确定数据帧(接收为“df”)是熊猫数据帧还是Spark数据帧?提前感谢。使用isinstance: if isinstance(df, pd.DataFrame): print('pandas') else: print('spark') 使用isinstance: if isinstance(df, pd.DataFrame):

我将数据帧传递给函数。有时是熊猫数据帧,有时是火花数据帧。我的职能部门需要采取相应行动。是否有一种简单的方法,例如df.isPandas(),来确定数据帧(接收为“df”)是熊猫数据帧还是Spark数据帧?提前感谢。

使用
isinstance

if isinstance(df, pd.DataFrame):
    print('pandas')
else:
    print('spark')

使用
isinstance

if isinstance(df, pd.DataFrame):
    print('pandas')
else:
    print('spark')

另一种方法是检查
df.schema.names
。这只是火花。实际上还有许多其他的区别,比如
.show()
。可能是一个很好的面试问题:)

另一种方法是检查
df.schema.names
。这只是火花。实际上还有许多其他的区别,比如
.show()
。可能是一个很好的面试问题:)

关于
type(df)
?关于
type(df)