Icon

kn_​forum_​37957_​python_​view_​example

Python View Example
Python View ExampleThis workflow shows how to create complex plots using your favorite python package. In this example, seaborn python package is used to create a 2D kernel density estimate (KDE) plot.please also see the Jupyter notebook in the sub-folder:/script/kn_forum_37957_python_view_example.ipynbRequirements:- KNIME Python Integration- seaborn package (how to install: https://seaborn.pydata.org/installing.html) import pandas as pd# load Iris dataset v_path_iris_data = flow_variables['var_path_data'] + "iris.csv"iris = pd.read_csv(v_path_iris_data) output_table = iris from io import BytesIOimport seaborn as snssns_plot = sns.jointplot(x=input_table['Petal.Length'], y=input_table['Sepal.Width'], fill=True, kind="kde")# Create buffer to write intobuffer = BytesIO()# Create plot and write it into the buffersns_plot.savefig(buffer, format='svg')# The output is the content of the bufferoutput_image = buffer.getvalue() kde plotusing seaborn packageload Iris datasetfrom /data/subfolderconda.environmentdata/SCRIPT TESTING.xlsxknime://knime.workflow/graphic/iris_from_knime.pngPython View Python Source collect meta data Conda EnvironmentPropagation Renderer to Image Table To Image Image To Table Merge Variables Excel Writer Image Writer (Port) Python View ExampleThis workflow shows how to create complex plots using your favorite python package. In this example, seaborn python package is used to create a 2D kernel density estimate (KDE) plot.please also see the Jupyter notebook in the sub-folder:/script/kn_forum_37957_python_view_example.ipynbRequirements:- KNIME Python Integration- seaborn package (how to install: https://seaborn.pydata.org/installing.html) import pandas as pd# load Iris dataset v_path_iris_data = flow_variables['var_path_data'] + "iris.csv"iris = pd.read_csv(v_path_iris_data) output_table = iris from io import BytesIOimport seaborn as snssns_plot = sns.jointplot(x=input_table['Petal.Length'], y=input_table['Sepal.Width'], fill=True, kind="kde")# Create buffer to write intobuffer = BytesIO()# Create plot and write it into the buffersns_plot.savefig(buffer, format='svg')# The output is the content of the bufferoutput_image = buffer.getvalue() kde plotusing seaborn packageload Iris datasetfrom /data/subfolderconda.environmentdata/SCRIPT TESTING.xlsxknime://knime.workflow/graphic/iris_from_knime.pngPython View Python Source collect meta data Conda EnvironmentPropagation Renderer to Image Table To Image Image To Table Merge Variables Excel Writer Image Writer (Port)

Nodes

Extensions

Links