Replies: 2 comments 5 replies
-
@SebbanSms correct , i can see the below error after assignment a custom variable to DF we need workaround or a solution to fix this kind of error |
Beta Was this translation helpful? Give feedback.
-
Your import pandas as pd
data = pd.DataFrame()
data.name = "some name"
data = data.copy()
print(data.name)
#> Traceback (most recent call last):
#> /tmp/ipykernel_79911/3401063958.py in <module>
#> ----> 1 print(data.name)
#> ~/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pandas/core/generic.py in __getattr__(self, name)
#> 5485 ):
#> 5486 return self[name]
#> -> 5487 return object.__getattribute__(self, name)
#> 5488
#> 5489 def __setattr__(self, name: str, value) -> None:
#> AttributeError: 'DataFrame' object has no attribute 'name' You can disable the copy with |
Beta Was this translation helpful? Give feedback.
-
Following an idea from stackoverflow to better keep track of data frames in logging messages
( https://stackoverflow.com/a/31727504/7269299 )
I assigned a .name attribute to some of my data frames in my code.
It seems that @check_types removes custom attributes from data frames:
This will raise an error as .name won't be available anymore inside the dumm_func whereas when I comment out
@check_types
this code works fine.Is this expected behavior? What can I do not to lose the attribute?
Beta Was this translation helpful? Give feedback.
All reactions