[Qgis-user] Write vector attribute table from pandas dataframe

Nicolas Cadieux njacadieux.gitlab at gmail.com
Sat Apr 23 10:33:57 PDT 2022


Hi Ming,

The best thing would be to show your code and ask others how it can be optimized.  I find that https://gis.stackexchange.com/ is the best place to do this but this user list definitely has some very  competent programmers.  Not being one of those competent programmers, I will just state that pandas and geopandas use a process called vectorization where the “for loop” is done for you.  

https://medium.com/analytics-vidhya/understanding-vectorization-in-numpy-and-pandas-188b6ebc5398

This means that looping over elements in a dataframe can be MUCH slower than using vectorization.  So basically, you need to figure out the right code and avoid “for loops“ when using dataframes.  

Hope this helps

Nicolas Cadieux
https://gitlab.com/njacadieux

> Le 22 avr. 2022 à 11:50, ming han via Qgis-user <qgis-user at lists.osgeo.org> a écrit :
> 
> 
> Hi everyone 
> 
>      Is there an efficient way to copy data in a pandas dataframe to the vector attribute table? 
> 
>       I am looping element by element, which is very slow. 
> 
> Thanks
> Ming 
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220423/140a85c1/attachment.html>


More information about the Qgis-user mailing list