You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know changing the function, as follows, will result in not creating an inplace update to aapl
deffind_trend(data: pd.DataFrame, period: int) ->Tuple[pd.Series, pd.Series]:
sma=data['Close'].rolling(period).mean() # does not create an inplace update to aapldiff=sma-sma.shift(1) # calculates a series of valuesgreater_than_0=diff>0# creates a series of boolsreturndiff, greater_than_0
Output of pd.show_versions()
INSTALLED VERSIONS
commit : d9fff27
python : 3.8.5.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
this is unrelated and has been the case since at least v0.22.0 (which is when I started using it)
you are mutating the dataframe in your function (since python is pass by reference and dataframes are mutable). Either pass in a copy of the dataframe or don't mutate the dataframe (as you suggested)
this is unrelated and has been the case since at least v0.22.0 (which is when I started using it)
you are mutating the dataframe in your function (since python is pass by reference and dataframes are mutable). Either pass in a copy of the dataframe or don't mutate the dataframe (as you suggested)
Thank you. I haven't passed dataframes to a function in this way, so I wasn't certain if this was the accepted behavior or not, and I couldn't find anything addressing the issue.
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Current Output
sma
columnProblem description
data['sma'] = data['Close'].rolling(period).mean()
to create an inplace update toaapl
Expected Output
Resolves Issue
aapl
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : d9fff27
python : 3.8.5.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 1.1.0
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.2
setuptools : 49.6.0.post20200814
Cython : 0.29.21
pytest : 6.0.1
hypothesis : None
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : 1.2.9
lxml.etree : 4.5.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: 0.9.0
bs4 : 4.9.1
bottleneck : 1.3.2
fsspec : 0.8.0
fastparquet : None
gcsfs : None
matplotlib : 3.3.1
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.4
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.0
sqlalchemy : 1.3.18
tables : 3.6.1
tabulate : 0.8.7
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.50.1
The text was updated successfully, but these errors were encountered: