pandas -将文本列插入Redshift表时出错 [英] Pandas - Error inserting text column into Redshift table
本文介绍了 pandas -将文本列插入Redshift表时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将文本列插入Redshift DB.
I am trying to insert a text column of into a Redshift DB.
我得到一个错误
DataError: value too long for type character varying(256)
下面给出的是我尝试过的代码.说明栏包含文字,长度最多2000个字符.
Given below is the code I tried. The description column has text and the length goes upto 2000 characters.
任何人都可以帮助我如何将此列插入表中.
Could anyone assist on how I could have this column inserted into the table.
DF['description'] = DF['description'].str[:200].astype(str)
任何人都可以帮忙,谢谢.
Could anyone assist, thanks.
推荐答案
您应该使用str.slice
.
df['description'] = df['description'].str.slice(0,255)
请注意,此功能仅在Strings
的情况下有效,否则您可能不得不打字.
Please note that this function works only in case of Strings
or you may have to typecast.
希望有帮助.
这篇关于 pandas -将文本列插入Redshift表时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文