我想替换文件中的数据类型,但是当我用字符串数组替换时它抛出错误。没有数组就可以正常工作。
我的更改-
[["int","null" ],['string','null'],['string','null'],[{"type": "long","logicalType": "timestamp-micros" },'null'],[{"type": "long","logicalType": "timestamp-micros" },'null'],['float','null']]
没有数组它的工作正常。 喜欢
['FLOAT','STRING','STRING','DATETIME','DATETIME','FLOAT']
dt_type_rep=dt_type.replace([r'NUMBER*([a-zA-Z_][a-zA-Z_0-9]*)',
r'VAR*([a-zA-Z_][a-zA-Z_0-9]*)',
r'CHAR*([a-zA-Z_][a-zA-Z_0-9]*)',
r'DATE*([a-zA-Z_][a-zA-Z_0-9]*)',
r'TIMESTAMP*([a-zA-Z_][a-zA-Z_0-9]*)',
r'FLOAT*([a-zA-Z_][a-zA-Z_0-9]*)'],
[["int","null" ],['string','null'],['string','null'],[{"type": "long","logicalType": "timestamp-micros" },'null'],[{"type": "long","logicalType": "timestamp-micros" },'null'],['float','null']],
regex=True)
Traceback (most recent call last):
File "schema_gen_for_data_fusion.py", line 33, in <module>
regex=True).format()
File "/home/mangeshc/anaconda3/lib/python3.7/site-packages/pandas/core/series.py", line 3432, in replace
regex=regex, method=method)
File "/home/mangeshc/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 5851, in replace
regex=regex)
File "/home/mangeshc/anaconda3/lib/python3.7/site-packages/pandas/core/internals.py", line 3754, in replace_list
mgr=mgr, convert=convert)
File "/home/mangeshc/anaconda3/lib/python3.7/site-packages/pandas/core/internals.py", line 2465, in replace
regex=regex, mgr=mgr)
File "/home/mangeshc/anaconda3/lib/python3.7/site-packages/pandas/core/internals.py", line 2512, in _replace_single
if isna(value) or not isinstance(value, compat.string_types):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()