Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello,
I can't figure this one out. I'm using Python on Power BI to do some data manipulation. My script runs fine in Jupyter notebook. Additionally, it runs fine in Power BI until I do a column assignment:
# Not a lot of code to get to this point
progress = df_installed.apply(lambda x: running_pct(x, deployment_totals), axis = 1)
# progress is a pd.Series with 141 float64 values
df_installed["Progress"] = progress
# If I comment this last line out, the script runs fine, but when I do the assignment, I get the error.
DataSource.Error: ADO.NET: Python script error.
Traceback (most recent call last):
File "C:\Users\user\esl\lib\site-packages\pandas\core\indexes\base.py", line 2646, in get_loc
return self._engine.get_loc(key)
File "pandas\_libs\index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Progress'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user\esl\lib\site-packages\pandas\core\internals\managers.py", line 1071, in set
loc = self.items.get_loc(item)
File "C:\Users\user\esl\lib\site-packages\pandas\core\indexes\base.py", line 2648, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas\_libs\index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Progress'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 30, in <module>
df_installed["Progress"] = progress
File "C:\Users\user\esl\lib\site-packages\pandas\core\frame.py", line 2938, in __setitem__
self._set_item(key, value)
File "C:\Users\user\esl\lib\site-packages\pandas\core\frame.py", line 3001, in _set_item
NDFrame._set_item(self, key, value)
File "C:\Users\user\esl\lib\site-packages\pandas\core\generic.py", line 3624, in _set_item
self._data.set(key, value)
File "C:\Users\user\esl\lib\site-packages\pandas\core\internals\managers.py", line 1074, in set
self.insert(len(self.items), item, value)
File "C:\Users\user\esl\lib\site-packages\pandas\core\internals\managers.py", line 1181, in insert
block = make_block(values=value, ndim=self.ndim, placement=slice(loc, loc + 1))
File "C:\Users\user\esl\lib\site-packages\pandas\core\internals\blocks.py", line 3053, in make_block
return klass(values, ndim=ndim, placement=placement)
File "C:\Users\user\esl\lib\site-packages\pandas\core\internals\blocks.py", line 124, in __init__
raise ValueError(
ValueError: Wrong number of items passed 3, placement implies 1
Details:
DataSourceKind=Python
DataSourcePath=Python
Message=Python script error.
Traceback (most recent call last):
File "C:\Users\user\esl\lib\site-packages\pandas\core\indexes\base.py", line 2646, in get_loc
return self._engine.get_loc(key)
File "pandas\_libs\index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Progress'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user\esl\lib\site-packages\pandas\core\internals\managers.py", line 1071, in set
loc = self.items.get_loc(item)
File "C:\Users\user\esl\lib\site-packages\pandas\core\indexes\base.py", line 2648, in get_loc
return self._engine.get_loc(self._maybe_cast_in...
ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Scripting.Python.Exceptions.PythonScriptRuntimeException
Hi @jumarinb ,
Please refer to the case.
Microsoft.PowerBI.Scripting.Python.Exceptions.PythonScriptRuntimeException-Transforming data python
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 35 | |
| 31 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 75 | |
| 72 | |
| 38 | |
| 35 | |
| 25 |