-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pandas2ri - requires pytz #1079
Labels
bug
Something isn't working
Comments
@dyrvte - Can you share a minimal code example to reproduce the issue? |
import rpy2.robjects as ro
from rpy2.robjects import pandas2ri as p2ri
from rpy2.robjects.conversion import localconverter
import pandas as pd
import pytz
from zoneinfo import ZoneInfo
from datetime import datetime
#works fine
record_for_prediction = pd.DataFrame([[datetime.now(),1]],columns =
["date","number"])
print(record_for_prediction)
context = localconverter(ro.default_converter + p2ri.converter)
with context as cv:
to_predict = cv.py2rpy(record_for_prediction )
#works fine
tz = pytz.UTC
record_for_prediction = pd.DataFrame([[datetime.now(tz),1]],columns =
["date","number"])
print(record_for_prediction)
context = localconverter(ro.default_converter + p2ri.converter)
with context as cv:
to_predict = cv.py2rpy(record_for_prediction )
#error occurs with this one
tz = ZoneInfo("UTC")
record_for_prediction = pd.DataFrame([[datetime.now(tz),1]],columns =
["date","number"])
print(record_for_prediction)
context = localconverter(ro.default_converter + p2ri.converter)
with context as cv:
to_predict = cv.py2rpy(record_for_prediction )
…On 30/12/2023, Laurent Gautier ***@***.***> wrote:
@dyrvte - Can you share a minimal code example to reproduce the issue?
--
Reply to this email directly or view it on GitHub:
#1079 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
Thanks I can't reproduce on this end with rpy2 3.5.15, and pandas 2.1.3. Can you share the output of python -m rpy2.situation and
|
Testing with 3.5.14 and 3.5.15 on my system gives the same error.
Pandas is 2.1.4, which I've just upgraded.
rpy2 version:
3.5.15
Python version:
3.11.6 (main, Nov 14 2023, 09:36:21) [GCC 13.2.1 20230801]
Looking for R's HOME:
Environment variable R_HOME: None
Calling `R RHOME`: /usr/lib64/R
Environment variable R_LIBS_USER: None
R's value for LD_LIBRARY_PATH:
/usr/lib64/R/lib:/usr/lib/jvm/java-21-openjdk/lib/server
R version:
In the PATH: R version 4.3.2 (2023-10-31) -- "Eye Holes"
Loading R library from rpy2: OK
Additional directories to load R packages from:
None
C extension compilation:
include:
['/usr/include/R/']
libraries:
['R', 'pcre2-8', 'lzma', 'bz2', 'z', 'tirpc', 'rt', 'dl', 'm',
'icuuc', 'icui18n']
library_dirs:
['/usr/lib64/R/lib']
extra_compile_args:
['-std=c99']
extra_link_args:
['-Wl,--export-dynamic', '-fopenmp',
'-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now', '-flto=auto']
Directory for the R shared library:
lib
CFFI extension type
Environment variable: RPY2_CFFI_MODE
Value: CFFI_MODE.ANY
ABI: PRESENT
API: PRESENT
python -c 'import pandas; print(pandas.__version__)'
2.1.4
…On 08/01/2024, Laurent Gautier ***@***.***> wrote:
Thanks I can't reproduce on this end with rpy2 3.5.15, and pandas 2.1.3. Can
you share the output of
```bash
python -m rpy2.situation
```
and
```
python -c 'import pandas; print(pandas.__version__)'
```
--
Reply to this email directly or view it on GitHub:
#1079 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
Also working with pandas 2.1.4 on this end. I have Python 3.10. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since ZoneInfo is now being used as the standard for Python I switched my pandas dataset from using pytz for timezones to ZoneInfo. It appears pandas2ri does not support this currently:
pandas2ri.py:65: UserWarning: Error while trying to convert the column ... Fall back to string conversion. The error is: 'zoneinfo.ZoneInfo' object has no attribute 'zone'
This attribute is not present in ZoneInfo
The text was updated successfully, but these errors were encountered: