Writing the shapefile to the CARTO account requires only a CartoContext object, a file path, and the usual URL and API key combination. With GeoPandas now installed, the MLB Stadiums shapefile can be loaded into a GeoPandas DataFrame, and then written to the CARTO account using the CartoContext write method:
import geopandas as gdpimport cartoframesAPIKEY = "{API KEY}"cc = cartoframes.CartoContext(base_url='https://{username}.carto.com/', api_key=APIKEY)shp = r"C:\Data\Stadiums_MLB\Stadiums_MLB.shp"data = gdp.read_file(shp)cc.write(data,"stadiums_mlb")
Log in to the CARTO account to confirm that the dataset has been added.