Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.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
Python 如何将数据帧的每列附加到熊猫中的序列?_Python_Pandas_Data Munging - Fatal编程技术网

Python 如何将数据帧的每列附加到熊猫中的序列?

Python 如何将数据帧的每列附加到熊猫中的序列?,python,pandas,data-munging,Python,Pandas,Data Munging,为什么每列都不会附加到系列中 id_names = pd.Series() for column in n_df: id_names.append(n_df[column].drop_duplicates(), ignore_index = True) id_names 无法将追加的结果重新分配给序列pd.Series.append不是就地方法。你需要重新分配 id_names = pd.Series() for column in n_df: id_names = id_na

为什么每列都不会附加到系列中

id_names = pd.Series()
for column in n_df:
    id_names.append(n_df[column].drop_duplicates(), ignore_index = True)
id_names

无法将追加的结果重新分配给序列
pd.Series.append
不是就地方法。你需要重新分配

id_names = pd.Series()
for column in n_df:
    id_names = id_names.append(n_df[column].drop_duplicates(), ignore_index = True)
id_names
但是,有一种更简单的方法来完成这项任务

尝试:


无法将追加的结果重新分配给序列
pd.Series.append
不是就地方法。你需要重新分配

id_names = pd.Series()
for column in n_df:
    id_names = id_names.append(n_df[column].drop_duplicates(), ignore_index = True)
id_names
但是,有一种更简单的方法来完成这项任务

尝试:


欢迎来到StackOverflow。请花点时间阅读这篇文章,以及如何提供答案,并相应地修改你的问题。这些提示也可能有用。请重新考虑将附加到序列作为附加到数据帧(即等长序列的字典)会导致效率低下。欢迎使用StackOverflow。请花点时间阅读这篇文章,以及如何提供答案,并相应地修改你的问题。这些提示可能也很有用。重新考虑将序列追加到数据帧(即等长序列的字典)会导致效率低下。