游客6742 于 2024-11-12 05:13:20 留言: Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\a - 副本.py", line 17, in <module>
close_prices = pd.to_numeric(close_prices, errors='coerce').dropna()
NameError: name 'pd' is not defined
游客5650 于 2024-11-12 05:12:16 留言: [*********************100%***********************] 1 of 1 completed
Warning (from warnings module):
File "C:\Users\Administrator\Desktop\a - 副本.py", line 17
close_prices = close_prices[close_prices.apply(lambda x: isinstance(x, (int, float)))]
UserWarning: Boolean Series key will be reindexed to match DataFrame index.
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\a - 副本.py", line 17, in <module>
close_prices = close_prices[close_prices.apply(lambda x: isinstance(x, (int, float)))]
File "C:\Python313\Lib\site-packages\pandas\core\frame.py", line 4093, in __getitem__
return self._getitem_bool_array(key)
File "C:\Python313\Lib\site-packages\pandas\core\frame.py", line 4149, in _getitem_bool_array
key = check_bool_indexer(self.index, key)
File "C:\Python313\Lib\site-packages\pandas\core\indexing.py", line 2662, in check_bool_indexer
raise IndexingError(
pandas.errors.IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).
游客2666 于 2024-11-12 05:12:09 留言: # 必须先安装 yfinance: pip install yfinance
import yfinance as yf
from datetime import datetime