1. Invalid comparison between dtype=datetime64[ns, America/New_York] and datetime64

Error

This error occurs when comparing timestamps in Yahoo Finance with different timezones.

Solution

To fix this error, we need to localize the timestamps to UTC before comparing them.

start = np.datetime64(datetime.date.today() - datetime.timedelta(days=freq))
df.index = df.index.tz_localize(None)  # Localize to UTC
df = df[start < df.index]

2. Could not import the lzma module

Error

This error occurs when importing pandas 1.0 or later with an incomplete Python installation.

Solution

To fix this error, we need to install the xz module using brew and reinstall pandas.

brew install xz
pyenv uninstall 3.7.3
pyenv install 3.7.3
pyenv global 3.7.3
pip install pandas