如何解决属性错误:'Series'对象没有属性'_mgr'



我试图在pandas中的一列上使用一个简单的.apply函数,这导致了这个错误。很快需要帮助。这是我的第一个问题,请忽略我的编辑和结构问题。

data = {'A':[1, 2, 3],  
'B':[4, 5, 6],  
'C':[7, 8, 9] } 
df = pd.DataFrame(data) 
df['add'] = df.apply(lambda row : row['A'] + row['B'] + row['C'], axis = 1)

我在Pandas中的任何简单.apply((函数中都会遇到这个错误。列上的任何应用程序((都会导致此问题。

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<command-2941072546244745> in <module>
3             'C':[7, 8, 9] } 
4 df = pd.DataFrame(data)
----> 5 df['add'] = df.apply(lambda row : row['A'] + row['B'] + row['C'], axis = 1)
/databricks/python/lib/python3.7/site-packages/pandas/core/frame.py in apply(self, func, axis, raw, result_type, args, **kwds)
6876              format.
6877         DataFrame.pivot_table : Create a spreadsheet-style pivot table
-> 6878              as a DataFrame.
6879 
6880         Notes
/databricks/python/lib/python3.7/site-packages/pandas/core/apply.py in get_result(self)
183             return self.apply_raw()
184 
--> 185         return self.apply_standard()
186 
187     def apply_empty_result(self):
/databricks/python/lib/python3.7/site-packages/pandas/core/apply.py in apply_standard(self)
274 
275     def apply_standard(self):
--> 276         results, res_index = self.apply_series_generator()
277 
278         # wrap results
/databricks/python/lib/python3.7/site-packages/pandas/core/apply.py in apply_series_generator(self)
301         else:
302             with option_context("mode.chained_assignment", None):
--> 303                 for i, v in enumerate(series_gen):
304                     # ignore SettingWithCopy here in case the user mutates
305                     results[i] = self.f(v)
/databricks/python/lib/python3.7/site-packages/pandas/core/apply.py in series_generator(self)
410         #  of it.  Kids: don't do this at home.
411         ser = self.obj._ixs(0, axis=0)
--> 412         mgr = ser._mgr
413         blk = mgr.blocks[0]
414 
/databricks/python/lib/python3.7/site-packages/pandas/core/generic.py in __getattr__(self, name)
5272         """
5273         Return a Numpy representation of the DataFrame.
-> 5274 
5275         .. warning::
5276 
AttributeError: 'Series' object has no attribute '_mgr'

当我尝试在azure-databricks集群上运行它时,由于集群管理问题而出现此问题。

清除状态并再次运行解决了问题。

_mgr通常是一个集群/编译器管理器问题。

相关内容

  • 没有找到相关文章

最新更新