Skip to content

Commit 60432f9

Browse files
committed
MAINT: Fix PDF for pandas 3 changes
Fix issues in FRED and FamaFrench
1 parent 0f90ea8 commit 60432f9

File tree

16 files changed

+49
-51
lines changed

16 files changed

+49
-51
lines changed

ci/azure/azure_template_posix.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ jobs:
1616
vmImage: ${{ parameters.vmImage }}
1717
strategy:
1818
matrix:
19-
python38_legacy:
20-
python.version: '3.8'
21-
PANDAS: 1.5.3
2219
python39_legacy:
2320
python.version: '3.9'
2421
PANDAS: 1.5.3
25-
python310_recent:
22+
python310_legacy:
2623
python.version: '3.9'
2724
PANDAS: 2.0.3
2825
python311_latest:
2926
python.version: '3.11'
27+
PANDAS: 2.1.4
3028
python312_latest:
3129
python.version: '3.12'
30+
python313_latest:
31+
python.version: '3.13'
3232

3333
steps:
3434
- task: UsePythonVersion@0

ci/azure/azure_template_windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ jobs:
1616
vmImage: ${{ parameters.vmImage }}
1717
strategy:
1818
matrix:
19-
python38_legacy:
20-
python.version: '3.8'
21-
PANDAS: 1.5.3
2219
python39_legecy:
2320
python.version: '3.9'
2421
PANDAS: 1.5.3
@@ -27,8 +24,11 @@ jobs:
2724
PANDAS: 2.0.3
2825
python311_latest:
2926
python.version: '3.11'
27+
PANDAS: 2.1.4
3028
python312_latest:
3129
python.version: '3.12'
30+
python313_latest:
31+
python.version: '3.13'
3232

3333
steps:
3434
- task: UsePythonVersion@0

pandas_datareader/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ def _read_url_as_StringIO(self, url, params=None):
115115
if len(text) == 0:
116116
service = self.__class__.__name__
117117
raise OSError(
118-
"{} request returned no data; check URL for invalid "
119-
"inputs: {}".format(service, self.url)
118+
"{} request returned no data; check URL for invalid inputs: {}".format(
119+
service, self.url
120+
)
120121
)
121122
if isinstance(text, bytes):
122123
out.write(text.decode("utf-8"))

pandas_datareader/data.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,7 @@ def DataReader(
683683
def Options(symbol, data_source=None, session=None):
684684
if data_source is None:
685685
warnings.warn(
686-
"Options(symbol) is deprecated, use Options(symbol,"
687-
" data_source) instead",
686+
"Options(symbol) is deprecated, use Options(symbol, data_source) instead",
688687
FutureWarning,
689688
stacklevel=2,
690689
)

pandas_datareader/famafrench.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ def read(self):
7878
def _read_one_data(self, url, params):
7979
params = {
8080
"index_col": 0,
81-
"parse_dates": [0],
82-
"date_parser": _parse_date_famafrench,
8381
}
8482

8583
# headers in these files are not valid
@@ -111,12 +109,14 @@ def _read_one_data(self, url, params):
111109
start = 0 if not match else match.start()
112110

113111
df = read_csv(StringIO("Date" + src[start:]), **params)
114-
try:
115-
idx_name = df.index.name # hack for pandas 0.16.2
116-
df = df.to_period(df.index.inferred_freq[:1])
117-
df.index.name = idx_name
118-
except Exception:
119-
pass
112+
if df.index.min() > 190000:
113+
df.index = to_datetime(df.index.astype(str), format="%Y%m").to_period(
114+
freq="M"
115+
)
116+
else:
117+
df.index = to_datetime(df.index.astype(str), format="%Y").to_period(
118+
freq="Y"
119+
)
120120
df = df.truncate(self.start, self.end)
121121
datasets[i] = df
122122

pandas_datareader/iex/daily.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
class IEXDailyReader(_DailyBaseReader):
18-
1918
"""
2019
Returns DataFrame of historical stock prices
2120
from symbols, over date range, start to end. To avoid being penalized by

pandas_datareader/moex.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ def read_all_boards(self):
197197

198198
if len(dfs) == 0:
199199
raise OSError(
200-
"{} returned no data; "
201-
"check URL or correct a date".format(self.__class__.__name__)
200+
"{} returned no data; check URL or correct a date".format(
201+
self.__class__.__name__
202+
)
202203
)
203204
elif len(dfs) > 1:
204205
b = pd.concat(dfs, axis=0, join="outer", sort=True)
@@ -226,8 +227,9 @@ def _read_url_as_String(self, url, params=None):
226227
if len(text) == 0:
227228
service = self.__class__.__name__
228229
raise OSError(
229-
"{} request returned no data; check URL for invalid "
230-
"inputs: {}".format(service, self.url)
230+
"{} request returned no data; check URL for invalid inputs: {}".format(
231+
service, self.url
232+
)
231233
)
232234
if isinstance(text, bytes):
233235
text = text.decode("windows-1251")

pandas_datareader/stooq.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
class StooqDailyReader(_DailyBaseReader):
5-
65
"""
76
Returns DataFrame/dict of Dataframes of historical stock prices from
87
symbols, over date range, start to end.

pandas_datareader/tests/test_famafrench.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def test_get_available_datasets(self):
3232

3333
def test_index(self):
3434
ff = web.DataReader("F-F_Research_Data_Factors", "famafrench")
35-
assert ff[0].index.freq == "M"
36-
assert ff[1].index.freq == "A-DEC"
35+
assert ff[0].index.freq.name == "ME"
36+
assert ff[1].index.freq.name == "YE-DEC"
3737

3838
def test_f_f_research(self):
3939
results = web.DataReader(
@@ -49,49 +49,49 @@ def test_f_f_research(self):
4949
{
5050
"Mkt-RF": [
5151
-3.36,
52-
3.40,
52+
3.4,
5353
6.31,
54-
2.00,
54+
2.0,
5555
-7.89,
5656
-5.57,
5757
6.93,
5858
-4.77,
5959
9.54,
6060
3.88,
61-
0.60,
61+
0.6,
6262
6.82,
6363
],
6464
"SMB": [
65-
0.40,
65+
0.4,
6666
1.19,
6767
1.48,
6868
4.87,
6969
0.09,
70-
-1.82,
71-
0.20,
72-
-3.00,
70+
-1.81,
71+
0.2,
72+
-3.0,
7373
3.96,
74-
1.14,
75-
3.77,
74+
1.13,
75+
3.76,
7676
0.73,
7777
],
7878
"HML": [
7979
0.43,
80-
3.23,
80+
3.22,
8181
2.21,
8282
2.89,
8383
-2.44,
84-
-4.70,
84+
-4.7,
8585
-0.31,
86-
-1.90,
86+
-1.9,
8787
-3.16,
88-
-2.43,
88+
-2.42,
8989
-0.96,
90-
3.70,
90+
3.69,
9191
],
9292
"RF": [
93-
0.00,
94-
0.00,
93+
0.0,
94+
0.0,
9595
0.01,
9696
0.01,
9797
0.01,
@@ -114,7 +114,7 @@ def test_f_f_research(self):
114114

115115
def test_me_breakpoints(self):
116116
results = web.DataReader(
117-
"ME_Breakpoints", "famafrench", start="2010-01-01", end="2010-12-01"
117+
"ME_Breakpoints", "famafrench", start="2010-01-01", end="2010-12-31"
118118
)
119119
assert isinstance(results, dict)
120120
assert len(results) == 2

pandas_datareader/tests/test_fred.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ def test_fred_nan(self):
3535
start = datetime(2010, 1, 1)
3636
end = datetime(2013, 1, 27)
3737
df = web.DataReader("DFII5", "fred", start, end)
38-
assert pd.isnull(df.loc["2010-01-01"][0])
38+
assert pd.isnull(df.loc["2010-01-01"].iloc[0])
3939

4040
def test_fred_parts(self): # pragma: no cover
4141
start = datetime(2010, 1, 1)
4242
end = datetime(2013, 1, 27)
4343
df = web.get_data_fred("CPIAUCSL", start, end)
44-
assert df.loc["2010-05-01"][0] == 217.29
44+
assert df.loc["2010-05-01"].iloc[0] == 217.29
4545

4646
t = df.CPIAUCSL.values
4747
assert np.issubdtype(t.dtype, np.floating)

pandas_datareader/tsp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
class TSPReader(_BaseReader):
5-
65
"""
76
Returns DataFrame of historical TSP fund prices from symbols, over date
87
range, start to end.

pandas_datareader/wb.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@
520520

521521

522522
class WorldBankReader(_BaseReader):
523-
524523
"""
525524
Download data series from the World Bank's World Development Indicators
526525

pandas_datareader/yahoo/headers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Default header
33
"""
4+
45
DEFAULT_HEADERS = {
56
"Connection": "keep-alive",
67
"Expires": str(-1),

pandas_datareader/yahoo/quotes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515

1616
class YahooQuotesReader(_BaseReader):
17-
1817
"""Get current yahoo quote"""
1918

2019
def __init__(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ select = ["B","C","E","F","W","T4","B9"]
8888

8989
[tool.black]
9090
target-version = ["py38", "py39", "py310","py311","py312"]
91-
required-version = "23.10.1"
91+
required-version = "25.1.0"
9292
exclude = """
9393
(
9494
pandas_datareader/_version.py

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
black==23.10.1
1+
black==25.1.0
22
isort>=5.12.0
33
flake8-bugbear
44
coverage

0 commit comments

Comments
 (0)