cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
] />

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
zetaVagabond1
Level III

JMP 19 Python Integration: ValueError: year 0 when converting Data Table to Pandas

Hello Everyone, 
I am upgrading my scripts from JMP18  to JMP19  and 'm hitting a particular roadblock with this integration. In JMP 18, I used custom function to loop through columns and create Pandas DataFrame. It worked perfectly. However in JMP19, the exact code throws a ValueError: year 0 is out of range. 
Here is the snippet: 
Python Send("raw_data");
def jmp_to_pandas(jmp_table):
    cols = list(jmp_table)
    data_dict = {}
    for col in cols:
        data_dict[col.name] = list(col)
    return pd.DataFrame(data_dict)
data1 = jmp_to_pandas(raw_data)
Questions:
  1. What is the official JMP 19 way to convert an open Data Table to a Pandas DataFrame?
  2. Has the jmp module structure changed? I'm finding it difficult to locate the updated JMP 19 Python API reference on the website.
  3. How should "Year 0" or JMP null dates (1904 epoch) be handled in JMP 19 to avoid Python datetime crashes?
2 REPLIES 2
jthi
Super User

Re: JMP 19 Python Integration: ValueError: year 0 when converting Data Table to Pandas

Going further with Python in JMP 19 is most likely a good starting point

-Jarmo

Re: JMP 19 Python Integration: ValueError: year 0 when converting Data Table to Pandas

For the latest information on the import jmp object's API see the Scripting Index 'Python' category in JMP.  Documentation and sample code provide the latest updates.  There are significant updates to the jmp module in 19.  

Given your function, I would say it's Pandas that is throwing the ValueError:.  Pandas has changed between its Python 3.11 version used in 18 and the Python 3.13 version utilized in JMP 19.  

See the Scripting index example on jmp.DataTable.from_dataframe().  There are multiple examples there, both to and from JMP data tables and other dataframe compatible Python objects:  Pandas; Polars; Ibis; ...

Specifically, 'Pandas to JMP' and 'JMP to Pandas' examples.

JMP to Pandas sample:

import jmp
import jmputils

try:
    if not jmputils.is_installed('pandas'):
        jmputils.jpip('install', 'pandas', echo=False)
except Exception as e:
    print(f'Install failed with exception: {e}')

import pandas as pd

dt = jmp.open(jmp.SAMPLE_DATA + "Big Class.jmp")
pandas_df = (pd.api.interchange.from_dataframe(dt))
print(pandas_df) 

 

Recommended Articles