0% found this document useful (0 votes)
2 views7 pages

While Code

The document outlines a workflow for performing univariate analysis using a while loop to iterate over a list of quantitative variables from a JSON data source. It details various nodes and their functions, including data extraction, statistical description, and handling missing values. The workflow is designed to utilize the pandas engine for data manipulation and analysis.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

While Code

The document outlines a workflow for performing univariate analysis using a while loop to iterate over a list of quantitative variables from a JSON data source. It details various nodes and their functions, including data extraction, statistical description, and handling missing values. The workflow is designed to utilize the pandas engine for data manipulation and analysis.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

{

"name": "Univariate Analysis While From JSON",


"description": "Equivalent workflow for ressources/whileCode_2.py. The while
loop iterates over list_quant only; the dataframe is used inside the loop body
and is not connected as a while input.",
"payload": {
"engine": "pandas",
"nodes": {
"node_dataframe_from_json": {
"block_type": "dataframe_from_json",
"params": {
"orient": "records",
"json_data": [
{
"age": 25,
"income": 3000,
"city": "Paris"
},
{
"age": 32,
"income": 4100,
"city": "Lyon"
},
{
"age": 40,
"income": 5200,
"city": "Marseille"
}
]
}
},
"node_list_quant": {
"block_type": "make_list",
"params": {
"items": [
[
"age"
],
[
"income"
]
]
}
},
"node_while_quant": {
"block_type": "while",
"params": {
"condition": "item is not None",
"max_iterations": 100
}
},
"node_select_col": {
"block_type": "select_columns",
"params": {}
},
"node_describe": {
"block_type": "describe",
"params": {
"percentiles": [
0.25,
0.75
]
}
},
"node_isna": {
"block_type": "isna",
"params": {}
},
"node_isna_sum": {
"block_type": "agg",
"params": {
"func": "sum"
}
},
"node_describe_dict": {
"block_type": "to_dict",
"params": {
"orient": "index"
}
},
"node_isna_dict": {
"block_type": "to_dict",
"params": {
"orient": "records"
}
},
"node_build_row": {
"block_type": "python_script",
"params": {
"code": "def scalar(v):\n if v is None:\n return
None\n try:\n if hasattr(v, 'item'):\n v =
[Link]()\n except Exception:\n pass\n try:\n if
isinstance(v, float) and v != v:\n return None\n except
Exception:\n pass\n return v\n\ncolumn = item[0] if isinstance(item,
list) and item else item\nstats_raw = desc_json or {}\nstats_rows =
stats_raw.values() if isinstance(stats_raw, dict) else stats_raw\nstats_map =
{}\nfor entry in stats_rows or []:\n if isinstance(entry, dict) and
[Link]('statistic') is not None:\n stats_map[entry['statistic']] =
entry\nisna_rows = isna_json or [{}]\nisna_map = isna_rows[0] if
isinstance(isna_rows, list) and isna_rows else {}\n\nrow = {\n 'variable':
column,\n 'count': scalar(stats_map.get('count',
{}).get(column)),\n 'isna': scalar(isna_map.get(column)),\n 'min':
scalar(stats_map.get('min', {}).get(column)),\n 'p25':
scalar(stats_map.get('25%', {}).get(column)),\n 'mean':
scalar(stats_map.get('mean', {}).get(column)),\n 'p75':
scalar(stats_map.get('75%', {}).get(column)),\n 'max':
scalar(stats_map.get('max', {}).get(column))\n}\n\noutputs = {'rows':
[row]}\n",
"inputs_schema": [
{
"name": "item",
"type": "JSON",
"required": true
},
{
"name": "desc_json",
"type": "JSON",
"required": true
},
{
"name": "isna_json",
"type": "JSON",
"required": true
}
],
"outputs_schema": [
{
"name": "rows",
"type": "LIST"
}
],
"language": "python"
}
},
"node_row_frame": {
"block_type": "dataframe_from_rows",
"params": {}
},
"node_merge_rows": {
"block_type": "merge_branch",
"params": {
"strategy": "append",
"accumulate": true,
"allow_empty": true
}
},
"node_gate_done": {
"block_type": "gate",
"params": {}
}
},
"graph": {
"node_dataframe_from_json": {
"x": 80,
"y": 220
},
"node_list_quant": {
"x": 80,
"y": 60
},
"node_while_quant": {
"x": 320,
"y": 60
},
"node_select_col": {
"x": 560,
"y": 140
},
"node_describe": {
"x": 800,
"y": 60
},
"node_isna": {
"x": 800,
"y": 180
},
"node_isna_sum": {
"x": 1040,
"y": 180
},
"node_describe_dict": {
"x": 1040,
"y": 60
},
"node_isna_dict": {
"x": 1280,
"y": 180
},
"node_build_row": {
"x": 1280,
"y": 60
},
"node_row_frame": {
"x": 1520,
"y": 60
},
"node_merge_rows": {
"x": 1760,
"y": 60
},
"node_gate_done": {
"x": 2000,
"y": 60
}
},
"connectors": [
{
"source_node": "node_list_quant",
"source": "list",
"target_node": "node_while_quant",
"target": "collection",
"target_kind": "param"
},
{
"source_node": "node_dataframe_from_json",
"source": "data",
"target_node": "node_select_col",
"target": "data",
"target_kind": "input"
},
{
"source_node": "node_while_quant",
"source": "item",
"target_node": "node_select_col",
"target": "columns",
"target_kind": "param"
},
{
"source_node": "node_select_col",
"source": "data",
"target_node": "node_describe",
"target": "data",
"target_kind": "input"
},
{
"source_node": "node_select_col",
"source": "data",
"target_node": "node_isna",
"target": "data",
"target_kind": "input"
},
{
"source_node": "node_isna",
"source": "data",
"target_node": "node_isna_sum",
"target": "data",
"target_kind": "input"
},
{
"source_node": "node_describe",
"source": "data",
"target_node": "node_describe_dict",
"target": "data",
"target_kind": "input"
},
{
"source_node": "node_isna_sum",
"source": "data",
"target_node": "node_isna_dict",
"target": "data",
"target_kind": "input"
},
{
"source_node": "node_while_quant",
"source": "item",
"target_node": "node_build_row",
"target": "item",
"target_kind": "input"
},
{
"source_node": "node_describe_dict",
"source": "json",
"target_node": "node_build_row",
"target": "desc_json",
"target_kind": "input"
},
{
"source_node": "node_isna_dict",
"source": "json",
"target_node": "node_build_row",
"target": "isna_json",
"target_kind": "input"
},
{
"source_node": "node_build_row",
"source": "rows",
"target_node": "node_row_frame",
"target": "rows",
"target_kind": "param"
},
{
"source_node": "node_row_frame",
"source": "data",
"target_node": "node_merge_rows",
"target": "branches",
"target_kind": "input"
},
{
"source_node": "node_merge_rows",
"source": "data",
"target_node": "node_gate_done",
"target": "data",
"target_kind": "input"
},
{
"source_node": "node_while_quant",
"source": "done",
"target_node": "node_gate_done",
"target": "branch",
"target_kind": "input"
}
],
"metadata": {
"engine": "pandas",
"name": "Univariate Analysis While From JSON"
}
}
}

You might also like