Apache Parquet 文件導入器此插件以交互方式導入 Apache Parquet 文件( https://parquet.apache.org/ ) 到 JMP 表中。
它由兩個命令組成:
- 單文件:選擇單個 .parquet 文件,檢查其有效性,然後在出現確認消息後創建並打開生成的 JMP 數據表,或者如果文件無效則發出警告消息;
- 多個文件:選擇包含所有 .parquet 文件的文件夾並打開生成的 JMP 表(注意:該文件夾必須包含僅有效.parquet 文件,沒有其他文件或子文件夾)
系統要求:
使用標準 Python 更新工具為您的 Python 配置安裝這些包。
注意:為了測試插件,您可以在此處找到示例 Parquet 文件: https://github.com/Teradata/kylo/tree/master/samples/sample-data/parquet
第三方集成回覆:Apache Parquet 檔案導入器最大限度,
我在 JMP Pro 17.2 中測試了該插件,以檢查加載透過 pandas 生成的 parquet 文件,但它不起作用,它無法識別該文件(即使我可以使用 Tad 等 parquet 讀取器程式讀取它)。
期待任何幫助,謝謝!
回覆:Apache Parquet 檔案導入器嗨,迪米戈,
你安裝了所有需要的Python套件了嗎?
如果是,請分享 JMP 日誌,以便我們更了解正在發生的情況。
順便說一句,JMP V18(預計於 2024 年 3 月發布)將具有更直接的 JMP-Python 鏈接,因此我們很可能會更新該插件。
乾杯,馬西莫
回覆:Apache Parquet 檔案導入器最大限度,
我想我已經得到了所有的包,這是我的設定:
Python版本3.11.7
numpy 版本 1.26.3
熊貓版本2.1.4
matplotlib 版本 3.8.0
scipy 版本 1.11.4
sqlite3(包含在Python基礎中)
PyQt5 版本 5.15.10
pyarrow 版本 14.0.2
我唯一能想到的是,我透過 conda 管理基礎環境上的包,不確定這是否存在衝突。或是Python在我的電腦上的設定方式...
這是 JMP 的日誌:
/*:
/*********/
將 numpy 導入為 np
將 pandas 導入為 pd
將 pyarrow 導入為 pa
將 pyarrow.parquet 導入為 pq
# 從 Parquet 格式讀取表
表 = pq.read_table(parquet_file)
# 將表轉換為 pandas 相容的 DataFrame
df = 表.to_pandas()
#打印(df)
/*********/
即使使用簡單的範例鑲木地板文件,我也會遇到相同的錯誤:

回覆:Apache Parquet 檔案導入器嗨,迪米戈,
配置看起來沒問題,conda 應該不是問題。
日誌沒有說太多。
您能否與我們分享您正在使用的 parquet 文件,以便我們可以直接使用它進行測試?
謝謝,馬西莫
回覆:Apache Parquet 檔案導入器使用原始連結中的範例檔案: https://github.com/Teradata/kylo/tree/master/samples/sample-data/parquet,也不起作用。所以我無法加載任何這些文件,我收到相同的錯誤訊息。
回覆:Apache Parquet 檔案導入器您好,應該不是這個問題,但可能與插件安裝有關,可能與 JMP Pro v17.2 衝突。
您能否嘗試在腳本視窗中複製並運行下面的腳本(沒有加載項),並告訴我它是否有效?
謝謝,馬西莫
//<BR />Names Default To Here( 1 );
// Pick Parquet file from directory
parquet_file_pf = Pick File( "Select Parquet File", , {"Parquet Files|parquet"} );
// Create Parquet_file string to pass to Python - exclude initial slash
parquet_file = Substr( parquet_file_pf, 2 );
// Extract Parquet file name without .parquet extension - to be used as JMP table name
parquet_filename = Word( -2, parquet_file, "/." );
// Show( parquet_file );
// Init Python connection
Python Init();
// Send Parquet complete file string to Python
Python Send( parquet_file );
//Python Submit( "print(parquet_file)" );
// Read Parquet file as a table, then read table as pandas DataFrame
Python Submit(
"\[
import numpy as np
import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
# Read a Table from Parquet format
table = pq.read_table(parquet_file)
# Convert Table to a pandas-compatible DataFrame
df = table.to_pandas()
#print(df)
]\"
);
// Get DataFrame as a JMP Data Table
dt = Python Get( df );
// check dt successfully imported
Try(
Is Missing( dt );
table_imported = 0;
,
table_imported = 1
);
// if dt is not a valid data table, set error message and close program
If( (table_imported == 0),
nw = New Window( "Import not successful", Modal, Text Box( "File " || parquet_filename || ".parquet is not a valid Parquet file" ) );
Stop();
);
// If dt is valid, continue execution
// Rename JMP Data Table as Parquet file name without extension
dt << Set Name( parquet_filename );
// Modal message window to confirm import
import_message = "File " || parquet_filename || ".parquet successfully imported";
nw = New Window( "Import successful", Modal, Text Box( import_message ) );
// Open JMP Data Table
dt << New Data View;
// Save JMP Data Table
// dt << Save();
// Terminate Python session
Python Term();
回覆:Apache Parquet 檔案導入器直接來自我的 JMP Discovery Summit 演示,這是一個用於處理 Parquet 檔案的 JMP 18 腳本,我們直接從 Parquet 列轉到 jmp.DataTable Python 物件。 JMP 18 允許從 Python 即時建立、讀取、修改 JMP 資料表。以下腳本使用 Teradtata 範例檔案之一,存取 parquet 檔案的架構並直接在 Python 中建立可比較的資料表列。以下內容直接從 JMP 18 中的Python感知腳本編輯器運行。
# parquet.py
# Author: Paul R. Nelson
# JMP Statistical Discovery LLC
#
# Description:
# Directly read a pyarrow table and create a JMP datatable. Discovered
# some issues in EA-5, that prevented this from working as desired,
# There is a conditional based on jmp.__version__ to check for EA-6
# or newer.
#
# The data for this file comes from a repository that is Apache licensed.
# https://github.com/Teradata/kylo/blob/master/samples/sample-data/parquet/userdata1.parquet
#
導入jmp
import pyarrow.parquet as pq
from pyarrow import types as ptypes
# verify JMP 18 EA-6 or newer
ver = jmp.__version__.split('.')
if(ver[0] == '0' and ver[1] < '6'):
print('This version requires JMP 18.0 EA-6 or newer.')
pq_Table = pq.read_table('/Users/me_me_me/Presentation/Parquet/userdata1.parquet')
# Create a helper function to build a JMP Column
# on DataTable 'dt' using parquet 'table', having column 'name'
def dtcol_from_pq_col_name(dt, table, name):
col = None
idx = table.schema.get_field_index(name)
col_type = table.schema[idx].type
print(f'{name}: {table.schema[idx].type}')
if ptypes.is_string(col_type):
col = dt.new_column(name, jmp.DataType.Character)
elif ptypes.is_date(col_type):
# This table does not contain a date column do this is unimplemented
print("FixMe: got a date column")
return None
elif ptypes.is_timestamp(col_type):
col = dt.new_column(name, jmp.DataType.Numeric)
# add JMP epoch time correction factor - 1Jan1904
timestamps = [ts.timestamp()+ 2082844800.0 for ts in table.column(idx).to_pylist()]
dt[name] = timestamps
# change column info to timestamp, and set an appropriate column width.
jmp.run_jsl(f'Data Table( "{dt.name}" ):{name} << Input Format( "yyyy-mm-dd" ) << Format( "yyyy-mm-ddThh:mm:ss", 19 ) << Set Display Width( 200 );')
else:
col = dt.new_column(name, jmp.DataType.Numeric) # Numeric
dt[名稱] = table.column(idx).to_pylist()
return col
# Create JMP data table with four of the columns from the table by name
dt = jmp.數據表('From Parquet', pq_Table.num_rows)
# could just as easily create all columns
# 對於 pq_Table.column_names 中的 n:
# instead of iterating on the list below
col_list = [ 'registration_dttm', 'first_name', 'last_name', 'salary']
for n in col_list:
dtcol_from_pq_col_name(dt, pq_Table, n)
# set column properties by calling JSL from Python. (格式和寬度)
jmp.run_jsl('''
// Change column display width: last_name
Data Table( "From Parquet" ):last_name << Set Display Width( 105 );
// Change column display width: Salary
Data Table( "From Parquet" ):salary << Set Display Width( 150 ) << Format( "Currency", "USD", 17, 2 );
''')
# display data about the parquet file
print(f'Table Rows: {len(pq_Table)}' )
print(f'Table Shape: {pq_Table.shape}')
print(f'Table Schema:\n{pq_Table.schema}')
print(pq_Table.schema.field('salary').type)
print(f'Column Names: {pq_Table.column_names}')
print(f'Num Columns: {pq_Table.num_columns}')
回覆:Apache Parquet 檔案導入器最大限度,
該腳本運行良好,我可以成功加載鑲木地板檔案。事實上,這將非常有用,我可以直接運行腳本來代替加載項。感謝您的好心幫助!
但該插件確實存在問題,在我目前安裝的 JMP Pro 中無法正常運作。但腳本會起作用。