verticapy.vDataFrame.to_geopandas#
- vDataFrame.to_geopandas(geometry: str) GeoDataFrame #
Converts the
vDataFrame
to a GeopandasDataFrame
.Warning
The data will be loaded in memory.
Parameters#
- geometry: str
Geometry
object used to create theGeoDataFrame
. It can also be a Geography object, which will be casted toGeometry
.
Returns#
- geopandas.GeoDataFrame
The
geopandas.GeoDataFrame
of the currentvDataFrame
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 fromverticapy
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()
123pop_estIntegerAbccontinentVarchar(32)AbccountryVarchar(82)AbcLong varchar(2411724)1 140 Seven seas (open ocean) Fr. S. Antarctic Lands 2 2931 South America Falkland Is. 3 4050 Antarctica Antarctica 4 57713 North America Greenland 5 265100 Asia N. Cyprus 6 279070 Oceania New Caledonia 7 282814 Oceania Vanuatu 8 329988 North America Bahamas 9 339747 Europe Iceland 10 360346 North America Belize 11 443593 Asia Brunei 12 591919 South America Suriname 13 594130 Europe Luxembourg 14 603253 Africa W. Sahara 15 642550 Europe Montenegro 16 647581 Oceania Solomon Is. 17 737718 South America Guyana 18 758288 Asia Bhutan 19 778358 Africa Eq. Guinea 20 865267 Africa Djibouti 21 920938 Oceania Fiji 22 1218208 North America Trinidad and Tobago 23 1221549 Asia Cyprus 24 1251581 Europe Estonia 25 1291358 Asia Timor-Leste 26 1467152 Africa eSwatini 27 1772255 Africa Gabon 28 1792338 Africa Guinea-Bissau 29 1895250 Europe Kosovo 30 1944643 Europe Latvia 31 1958042 Africa Lesotho 32 1972126 Europe Slovenia 33 2051363 Africa Gambia 34 2103721 Europe Macedonia 35 2214858 Africa Botswana 36 2314307 Asia Qatar 37 2484780 Africa Namibia 38 2823859 Europe Lithuania 39 2875422 Asia Kuwait 40 2990561 North America Jamaica 41 3045191 Asia Armenia 42 3047987 Europe Albania 43 3068243 Asia Mongolia 44 3351827 North America Puerto Rico 45 3360148 South America Uruguay 46 3424386 Asia Oman 47 3474121 Europe Moldova 48 3500000 Africa Somaliland 49 3753142 North America Panama 50 3758571 Africa Mauritania 51 3856181 Europe Bosnia and Herz. 52 4292095 Europe Croatia 53 4510327 Oceania New Zealand 54 4543126 Asia Palestine 55 4689021 Africa Liberia 56 4926330 Asia Georgia 57 4930258 North America Costa Rica 58 4954674 Africa Congo 59 5011102 Europe Ireland 60 5320045 Europe Norway 61 5351277 Asia Turkmenistan 62 5445829 Europe Slovakia 63 5491218 Europe Finland 64 5605948 Europe Denmark 65 5625118 Africa Central African Rep. 66 5789122 Asia Kyrgyzstan 67 5918919 Africa Eritrea 68 6025951 North America Nicaragua 69 6072475 Asia United Arab Emirates 70 6163195 Africa Sierra Leone 71 6172011 North America El Salvador 72 6229794 Asia Lebanon 73 6653210 Africa Libya 74 6909701 Oceania Papua New Guinea 75 6943739 South America Paraguay 76 7101510 Europe Bulgaria 77 7111024 Europe Serbia 78 7126706 Asia Laos 79 7531386 Africa Somalia 80 7965055 Africa Togo 81 8236303 Europe Switzerland 82 8299706 Asia Israel 83 8468555 Asia Tajikistan 84 8754413 Europe Austria 85 9038741 North America Honduras 86 9549747 Europe Belarus 87 9850845 Europe Hungary 88 9960487 Europe Sweden 89 9961396 Asia Azerbaijan 90 10248069 Asia Jordan 91 10646714 North America Haiti 92 10674723 Europe Czechia 93 10734247 North America Dominican Rep. 94 10768477 Europe Greece 95 10839514 Europe Portugal 96 11038805 Africa Benin 97 11138234 South America Bolivia 98 11147407 North America Cuba 99 11403800 Africa Tunisia 100 11466756 Africa Burundi Rows: 1-100 | Columns: 4Note
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 GeopandasDataFrame
.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