Thanks Rog, I did originally use the to_sql method (and re-tried after seeing your comment) and I agree it seems to function much better in maintaining datatypes and is much easier to type. However, I have found the occasional dataset where I seem get issues using this, and so I reverted to the method above. Although this may be due to my implementation of it.

These seem to be reasonably rare cases and is something I need to look into more, I’ve included an example of your method here for those that are interested.

I agree on the str.join point, it’s much more elegant using this and so I’ve updated my code with this.

Thanks a lot for the feedback!

Written by

Data scientist learning and writing about everything.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store