如何解决在Power BI中使用python脚本处理SQL数据框
我想在Power BI上的SQL数据帧上执行一个简单的python脚本。 但是错误似乎表明SQL表已被读取为CSV文件,并且我不知道为什么脚本将数据框视为CSV文件而不是SQL数据框。
python脚本是:import pandas as pd
dataset['COD-MARQ'] = dataset['COD-MARQ'].str.strip()
关于我应该如何处理的任何想法?
谢谢
Traceback (most recent call last):
File "PythonScriptWrapper.PY",line 7,in <module>
df1 = pandas.read_csv('input_df_da064532-6620-4e48-a091-ff580b127759.csv')
File "C:\Users\afalieres\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\io\parsers.py",line 686,in read_csv
return _read(filepath_or_buffer,kwds)
File "C:\Users\afalieres\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\io\parsers.py",line 458,in _read
data = parser.read(nrows)
File "C:\Users\afalieres\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\io\parsers.py",line 1186,in read
ret = self._engine.read(nrows)
File "C:\Users\afalieres\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\io\parsers.py",line 2145,in read
data = self._reader.read(nrows)
File "pandas\_libs\parsers.pyx",line 847,in pandas._libs.parsers.TextReader.read
File "pandas\_libs\parsers.pyx",line 862,in pandas._libs.parsers.TextReader._read_low_memory
File "pandas\_libs\parsers.pyx",line 941,in pandas._libs.parsers.TextReader._read_rows
File "pandas\_libs\parsers.pyx",line 1073,in pandas._libs.parsers.TextReader._convert_column_data
File "pandas\_libs\parsers.pyx",line 1119,in pandas._libs.parsers.TextReader._convert_tokens
File "pandas\_libs\parsers.pyx",line 1194,in pandas._libs.parsers.TextReader._convert_with_dtype
File "pandas\_libs\parsers.pyx",line 1814,in pandas._libs.parsers._try_int64
MemoryError: Unable to allocate 64.0 KiB for an array with shape (8192,) and data type int64
Détails :
DataSourceKind=Python
DataSourcePath=Python
Message=Ρŷтнőŋ şсŗĩрţ εггǿŗ.
Traceback (most recent call last):
File "PythonScriptWrapper.PY",in pandas._libs.parsers.Tex...
ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Scripting.Python.Exceptions.PythonScriptRuntimeException ```
解决方法
我不是很肯定这是问题所在,但在我看来dataset
是指上一步而不是原始来源,这意味着它不再是SQL数据帧格式。您可能想使用python导入原始源,或者修改脚本以将数据集不视为SQL数据框,而是以任何形式将查询编辑器传递给python脚本(我认为是一个熊猫数据框)。
另外,在这种情况下,似乎没有必要使用python进行简单的转换,而该转换可以很容易地在M中进行。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。