Loading...

verticapy.vDataFrame.to_geopandas#

vDataFrame.to_geopandas(geometry: str) GeoDataFrame#

Converts the vDataFrame to a Geopandas DataFrame.

Warning

The data will be loaded in memory.

Parameters#

geometry: str

Geometry object used to create the GeoDataFrame. It can also be a Geography object, which will be casted to Geometry.

Returns#

geopandas.GeoDataFrame

The geopandas.GeoDataFrame of the current vDataFrame relation.

Examples#

We import verticapy:

import verticapy as vp

Hint

By assigning an alias to verticapy, we mitigate the risk of code collisions with other libraries. This precaution is necessary because verticapy uses commonly known function names like “average” and “median”, which can potentially lead to naming conflicts. The use of an alias ensures that the functions from verticapy are used as intended without interfering with functions from other libraries.

For this example, we will use the World dataset.

import verticapy.datasets as vpd

data = vpd.load_world()
123
pop_est
Integer
Abc
continent
Varchar(32)
Abc
country
Varchar(82)
Abc
Long varchar(2411724)
1140Seven seas (open ocean)Fr. S. Antarctic Lands
22931South AmericaFalkland Is.
34050AntarcticaAntarctica
457713North AmericaGreenland
5265100AsiaN. Cyprus
6279070OceaniaNew Caledonia
7282814OceaniaVanuatu
8329988North AmericaBahamas
9339747EuropeIceland
10360346North AmericaBelize
11443593AsiaBrunei
12591919South AmericaSuriname
13594130EuropeLuxembourg
14603253AfricaW. Sahara
15642550EuropeMontenegro
16647581OceaniaSolomon Is.
17737718South AmericaGuyana
18758288AsiaBhutan
19778358AfricaEq. Guinea
20865267AfricaDjibouti
21920938OceaniaFiji
221218208North AmericaTrinidad and Tobago
231221549AsiaCyprus
241251581EuropeEstonia
251291358AsiaTimor-Leste
261467152AfricaeSwatini
271772255AfricaGabon
281792338AfricaGuinea-Bissau
291895250EuropeKosovo
301944643EuropeLatvia
311958042AfricaLesotho
321972126EuropeSlovenia
332051363AfricaGambia
342103721EuropeMacedonia
352214858AfricaBotswana
362314307AsiaQatar
372484780AfricaNamibia
382823859EuropeLithuania
392875422AsiaKuwait
402990561North AmericaJamaica
413045191AsiaArmenia
423047987EuropeAlbania
433068243AsiaMongolia
443351827North AmericaPuerto Rico
453360148South AmericaUruguay
463424386AsiaOman
473474121EuropeMoldova
483500000AfricaSomaliland
493753142North AmericaPanama
503758571AfricaMauritania
513856181EuropeBosnia and Herz.
524292095EuropeCroatia
534510327OceaniaNew Zealand
544543126AsiaPalestine
554689021AfricaLiberia
564926330AsiaGeorgia
574930258North AmericaCosta Rica
584954674AfricaCongo
595011102EuropeIreland
605320045EuropeNorway
615351277AsiaTurkmenistan
625445829EuropeSlovakia
635491218EuropeFinland
645605948EuropeDenmark
655625118AfricaCentral African Rep.
665789122AsiaKyrgyzstan
675918919AfricaEritrea
686025951North AmericaNicaragua
696072475AsiaUnited Arab Emirates
706163195AfricaSierra Leone
716172011North AmericaEl Salvador
726229794AsiaLebanon
736653210AfricaLibya
746909701OceaniaPapua New Guinea
756943739South AmericaParaguay
767101510EuropeBulgaria
777111024EuropeSerbia
787126706AsiaLaos
797531386AfricaSomalia
807965055AfricaTogo
818236303EuropeSwitzerland
828299706AsiaIsrael
838468555AsiaTajikistan
848754413EuropeAustria
859038741North AmericaHonduras
869549747EuropeBelarus
879850845EuropeHungary
889960487EuropeSweden
899961396AsiaAzerbaijan
9010248069AsiaJordan
9110646714North AmericaHaiti
9210674723EuropeCzechia
9310734247North AmericaDominican Rep.
9410768477EuropeGreece
9510839514EuropePortugal
9611038805AfricaBenin
9711138234South AmericaBolivia
9811147407North AmericaCuba
9911403800AfricaTunisia
10011466756AfricaBurundi
Rows: 1-100 | Columns: 4

Note

VerticaPy offers a wide range of sample datasets that are ideal for training and testing purposes. You can explore the full list of available datasets in the Datasets, which provides detailed information on each dataset and how to use them effectively. These datasets are invaluable resources for honing your data analysis and machine learning skills within the VerticaPy environment.

Let’s convert the vDataFrame to a Geopandas DataFrame.

data.to_geopandas(geometry = "geometry")
pop_est continent country geometry
0 140 Seven seas (open ocean) Fr. S. Antarctic Lands POLYGON ((68.93500 -48.62500, 69.58000 -48.94000, 70.52500 -49.06500, 70.56000 -49.25500, 70.28000 -49.71000, 68.74500 -49.77500, 68.72000 -49.24250, 68.86750 -48.83000, 68.93500 -48.62500))
... ... ... ... ...
176 1379302771 Asia China MULTIPOLYGON (((109.47521 18.19770, 108.65521 18.50768, 108.62622 19.36789, 109.11906 19.82104, 110.21160 20.10125, 110.78655 20.07753, 111.01005 19.69593, 110.57065 19.25588, 110.33919 18.67840, 109.47521 18.19770)), ((80.25999 42.35000, 80.18015 42.92007, 80.86621 43.18036, 79.96611 44.91752, 81.94707 45.31703, 82.45893 45.53965, 83.18048 47.33003, 85.16429 47.00096, 85.72048 47.45297, 85.76823 48.45575, 86.59878 48.54918, 87.35997 49.21498, 87.75126 49.29720, 88.01383 48.59946, 88.85430 48.06908, 90.28083 47.69355, 90.97081 46.88815, 90.58577 45.71972, 90.94554 45.28607, 92.13389 45.11508, 93.48073 44.97547, 94.68893 44.35233, 95.30688 44.24133, 95.76245 43.31945, 96.34940 42.72564, 97.45176 42.74889, 99.51582 42.52469, 100.84587 42.66380, 101.83304 42.51487, 103.31228 41.90747, 104.52228 41.90835, 104.96499 41.59741, 106.12932 42.13433, 107.74477 42.48152, 109.24360 42.51945, 110.41210 42.87123, 111.12968 43.40683, 111.82959 43.74312, 111.66774 44.07318, 111.34838 44.45744, 111.87331 45.10208, 112.43606 45.01165, 113.46391 44.80889, 114.46033 45.33982, 115.98510 45.72724, 116.71787 46.38820, 117.42170 46.67273, 118.87433 46.80541, 119.66327 46.69268, 119.77282 47.04806, 118.86657 47.74706, 118.06414 48.06673, 117.29551 47.69771, 116.30895 47.85341, 115.74284 47.72654, 115.48528 48.13538, 116.19180 49.13460, 116.67880 49.88853, 117.87924 49.51098, 119.28846 50.14288, 119.27939 50.58292, 120.18208 51.64355, 120.73820 51.96411, 120.72579 52.51623, 120.17709 52.75389, 121.00308 53.25140, 122.24575 53.43173, 123.57147 53.45880, 125.06821 53.16104, 125.94635 52.79280, 126.56440 51.78426, 126.93916 51.35389, 127.28746 50.73980, 127.65740 49.76027, 129.39782 49.44060, 130.58229 48.72969, 130.98726 47.79013, 132.50669 47.78896, 133.37360 48.18344, 135.02631 48.47823, 134.50081 47.57845, 134.11235 47.21248, 133.76964 46.11693, 133.09712 45.14409, 131.88345 45.32116, 131.02519 44.96796, 131.28856 44.11152, 131.14469 42.92999, 130.63387 42.90301, 130.64000 42.39502, 129.99427 42.98539, 129.59667 42.42498, 128.05222 41.99428, 128.20843 41.46677, 127.34378 41.50315, 126.86908 41.81657, 126.18205 41.10734, 125.07994 40.56982, 124.26562 39.92849, 122.86757 39.63779, 122.13139 39.17045, 121.05455 38.89747, 121.58599 39.36085, 121.37676 39.75026, 122.16860 40.42244, 121.64036 40.94639, 120.76863 40.59339, 119.63960 39.89806, 119.02346 39.25233, 118.04275 39.20427, 117.53270 38.73764, 118.05970 38.06148, 118.87815 37.89733, 118.91164 37.44846, 119.70280 37.15639, 120.82346 37.87043, 121.71126 37.48112, 122.35794 37.45448, 122.51999 36.93061, 121.10416 36.65133, 120.63701 36.11144, 119.66456 35.60979, 119.15121 34.90986, 120.22752 34.36033, 120.62037 33.37672, 121.22901 32.46032, 121.90815 31.69217, 121.89192 30.94935, 121.26426 30.67627, 121.50352 30.14291, 122.09211 29.83252, 121.93843 29.01802, 121.68444 28.22551, 121.12566 28.13567, 120.39547 27.05321, 119.58550 25.74078, 118.65687 24.54739, 117.28161 23.62450, 115.89074 22.78287, 114.76383 22.66807, 114.15255 22.22376, 113.80678 22.54834, 113.24108 22.05137, 111.84359 21.55049, 110.78547 21.39714, 110.44404 20.34103, 109.88986 20.28246, 109.62766 21.00823, 109.86449 21.39505, 108.52281 21.71521, 108.05018 21.55238, 107.04342 21.81190, 106.56727 22.21820, 106.72540 22.79427, 105.81125 22.97689, 105.32921 23.35206, 104.47686 22.81915, 103.50451 22.70376, 102.70699 22.70880, 102.17044 22.46475, 101.65202 22.31820, 101.80312 21.17437, 101.27003 21.20165, 101.18001 21.43657, 101.15003 21.84998, 100.41654 21.55884, 99.98349 21.74294, 99.24090 22.11831, 99.53199 22.94904, 98.89875 23.14272, 98.66026 24.06329, 97.60472 23.89740, 97.72461 25.08364, 98.67184 25.91870, 98.71209 26.74354, 98.68269 27.50881, 98.24623 27.74722, 97.91199 28.33595, 97.32711 28.26158, 96.24883 28.41103, 96.58659 28.83098, 96.11768 29.45280, 95.40480 29.03172, 94.56599 29.27744, 93.41335 28.64063, 92.50312 27.89688, 91.69666 27.77174, 91.25885 28.04061, 90.73051 28.06495, 90.01583 28.29644, 89.47581 28.04276, 88.81425 27.29932, 88.73033 28.08686, 88.12044 27.87654, 86.95452 27.97426, 85.82332 28.20358, 85.01164 28.64277, 84.23458 28.83989, 83.89899 29.32023, 83.33712 29.46373, 82.32751 30.11527, 81.52580 30.42272, 81.11126 30.18348, 79.72137 30.88271, 78.73889 31.51591, 78.45845 32.61816, 79.17613 32.48378, 79.20889 32.99439, 78.81109 33.50620, 78.91227 34.32194, 77.83745 35.49401, 76.19285 35.89840, 75.89690 36.66681, 75.15803 37.13303, 74.98000 37.41999, 74.82999 37.99001, 74.86482 38.37885, 74.25751 38.60651, 73.92885 38.50582, 73.67538 39.43124, 73.96001 39.66001, 73.82224 39.89397, 74.77686 40.36643, 75.46783 40.56207, 76.52637 40.42795, 76.90448 41.06649, 78.18720 41.18532, 78.54366 41.58224, 80.11943 42.12394, 80.25999 42.35000)))

Warning

Exporting to an in-memory object can take time if the data is massive. It is recommended to downsample the data before using such a function.

See also

vDataFrame.to_db() : Saves the current structure of vDataFrame to the Vertica Database.
vDataFrame.to_json() : Creates a JSON file of the current vDataFrame structure.