question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError in pandas._libs.tslibs.period._ordinal_from_fields

See original GitHub issue

Using pandas 0.23.3 I receive a TypeErorr when running the following code:

import pandas
ts = pandas.date_range('2017-01-01', '2018-01-01', freq='B')
months = ts.map(lambda x: pandas.Period(year=x.year, month=x.month, freq='M'))
# Screen output even though operation succeeds.
# TypeError                                 Traceback (most recent call last)
# TypeError: an integer is required
# Exception TypeError: 'an integer is required' in 'pandas._libs.tslibs.period._ordinal_from_fields' ignored

Oddly, enough the operation succeeds, months has the correct data.

Expected Output

I would expect no output to stderr or stdout, just the correct assignment of the map operation. This is more of an annoyance than anything else.

Output of pd.show_versions()

pandas.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.15.final.0
python-bits: 64
OS: Darwin
OS-release: 17.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.23.3
pytest: None
pip: 18.0
setuptools: 40.0.0
Cython: None
numpy: 1.13.0
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 5.7.0
sphinx: None
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: 3.4.4
numexpr: 2.6.6
feather: None
matplotlib: 2.2.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0.1
sqlalchemy: 1.2.10
pymysql: 0.9.2
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

[paste the output of pd.show_versions() here below this line]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
WillAydcommented, Jul 26, 2018

@mosrosem just to be clear it’s not actually throwing the error (at least for me) but rather printing to STDOUT and continuing along as planned. If it’s not doing for you can you post your pd.show_versions?

0reactions
WillAydcommented, Jul 28, 2018

@jbrockmendel I was thinking of CC’ing you 😃 looks like you might be on to something

Read more comments on GitHub >

github_iconTop Results From Across the Web

Date converted to <class 'pandas._libs.tslibs.timestamps ...
iloc[0])) the type is coming <class 'pandas._libs.tslibs.timestamps.Timestamp'> but I wanted to convert it to datetime.datetime format. What am ...
Read more >
pandas.Timestamp — pandas 1.5.2 documentation
Convert a Timestamp object to a native Python datetime object. today ([tz]). Return the current time in the local timezone.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found