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.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive