ValueError: The truth value ...
Hi Folks,
I'm having an issue with a Python tile in Magic ETL , the code works on my machine (pycharm) but throws an error once in Domo (this happens often, what's the difference?)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.al
The goal is to produce a string value surfacing the differences between two strings, which column the difference has come from, and the position of the differences within the columns.
I define a function that achieves this, then use this function in a loop, iterating through the values in two DataFrame columns, extracting the differences, and replacing a temp DataFrame's values with these outputs.
# imports
import the domomagic package into the script from domomagic import *
import pandas as pd # read data from inputs into a data frame df = read_dataframe('Filter Rows') # Function def char_position(d,p):
z = set(d)
y = set(p)
zy_diff = z.symmetric_difference(y)
list_set = list(zy_diff)
l_2 = []
for x in range(len(zy_diff)):
try:
l_2.append(f'"{list_set[x]}" - Column_One - position {d.index(list_set[x])+1} ')
except:
pass
try:
l_2.append(f'"{list_set[x]}" - Column_Two - position {p.index(list_set[x])+1}')
except:
pass
return l_2 # Getting the original DataFrame's length weh = range(len(df.index))
# Creating a temp DataFrame using the original DataFrame's length uni = pd.DataFrame({'header':'value'},index=weh) # Executing the function against to DataFrame columns # and replacing the temp values in the temp DataFrame for x in weh:
ide = str(df['Column_One'][x]).split()
pjr = str(df['Column_Two'][x]).split()
uni.iloc[x] = [char_position(ide,pjr)] write_dataframe(uni)
^ the code box is greying out everything once published - not intentional.
All help appreciated
Answers
-
Which version of python are you using locally and which version is your script using?
import sys print(sys.version)
Is it giving you a line number which is causing the error?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
Version: 3.10.5
Full error message:
00:00:02.282 Traceback (most recent call last): 00:00:02.282 Traceback (most recent call last): 00:00:02.282 File "<stdin>", line 40, in <module> 00:00:02.282 File "/home/domo/domomagic/io.py", line 48, in write_dataframe 00:00:02.282 write_array_dict(d) 00:00:02.283 File "/home/domo/domomagic/io.py", line 69, in write_array_dict 00:00:02.283 write_lenstrings(path, a) 00:00:02.283 File "/home/domo/domomagic/lenstrings.py", line 22, in write_lenstrings 00:00:02.283 _write_string(f, s) 00:00:02.283 File "/home/domo/domomagic/lenstrings.py", line 41, in _write_string 00:00:02.283 if pd.isnull(value): 00:00:02.283 ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive