vDataFrame.to_csv

In [ ]:
vDataFrame.to_csv(path: str, 
                  sep: str = ',',
                  na_rep: str = '',
                  quotechar: str = '"',
                  usecols: list = [],
                  header: bool = True,
                  new_header: list = [],
                  order_by = [],
                  n_files: int = 1,)

Creates a CSV file or folder of CSV files of the current vDataFrame relation.

Parameters

Name Type Optional Description
path
str
File/Folder system path. Be careful: if a CSV file with the same name exists, it will over-write it.
sep
str
Column separator.
na_rep
str
Missing values representation.
quotechar
str
Char which will enclose the str values.
usecols
list
vcolumns to select from the final vDataFrame relation. If empty, all the vcolumns will be selected.
header
bool
If set to False, no header will be written in the CSV file.
new_header
list
List of columns to use to replace vcolumns name in the CSV.
order_by
dict / list
List of the vcolumns to use to sort the data using asc order or dictionary of all the sorting methods. For example, to sort by "column1" ASC and "column2" DESC, write {"column1": "asc", "column2": "desc"}
n_files
int
Integer greater than or equal to one, the number of CSV files to generate. If n_files is greater than one, you must use order_by to sort the data, ideally with a column of unique values (e.g. ID). Increasing the value of n_files decreases memory usage, but increases execution time.

Returns

vDataFrame : self

Example

In [97]:
from verticapy.datasets import load_titanic
titanic = load_titanic()
display(titanic)
123
fare
Numeric(10,5)
123
survived
Int
Abc
sex
Varchar(20)
Abc
boat
Varchar(100)
123
pclass
Int
123
age
Numeric(6,3)
Abc
ticket
Varchar(36)
Abc
Varchar(164)
Abc
embarked
Varchar(20)
Abc
cabin
Varchar(30)
123
body
Int
123
parch
Int
Abc
home.dest
Varchar(100)
123
sibsp
Int
1151.550000female[null]12.000113781SC22 C26[null]2Montreal, PQ / Chesterville, ON1
2151.550000male[null]130.000113781SC22 C261352Montreal, PQ / Chesterville, ON1
3151.550000female[null]125.000113781SC22 C26[null]2Montreal, PQ / Chesterville, ON1
40.000000male[null]139.000112050SA36[null]0Belfast, NI0
549.504200male[null]171.000PC 17609C[null]220Montevideo, Uruguay0
6227.525000male[null]147.000PC 17757CC62 C641240New York, NY1
725.925000male[null]1[null]PC 17318S[null][null]0New York, NY0
8247.520800male[null]124.000PC 17558CB58 B60[null]1Montreal, PQ0
975.241700maleA136.00013050CC6[null]0Winnipeg, MN0
1026.000000male[null]125.00013905C[null]1480San Francisco, CA0
1135.500000male[null]145.000113784ST[null]0Trenton, NJ0
1226.550000male[null]142.000110489SD22[null]0London / Winnipeg, MB0
1330.500000male[null]141.000113054SA21[null]0Pomeroy, WA0
1450.495800male[null]148.000PC 17591CB102080Omaha, NE0
1539.600000male[null]1[null]112379C[null][null]0Philadelphia, PA0
1626.550000male[null]145.000113050SB38[null]0Washington, DC0
1731.000000male[null]1[null]113798S[null][null]0[null]0
185.000000male[null]133.000695SB51 B53 B55[null]0New York, NY0
1947.100000male[null]128.000113059S[null][null]0Montevideo, Uruguay0
2047.100000male[null]117.000113059S[null][null]0Montevideo, Uruguay0
2126.000000male[null]149.00019924S[null][null]0Ascot, Berkshire / Rochester, NY0
2278.850000male[null]136.00019877SC461720Little Onn Hall, Staffs1
2361.175000male[null]146.000W.E.P. 5734SE31[null]0Amenia, ND1
240.000000male[null]1[null]112051S[null][null]0Liverpool, England / Belfast0
25136.779200male[null]127.00013508CC89[null]0Los Angeles, CA1
2652.000000male[null]1[null]110465SA14[null]0Stoughton, MA0
2725.587500male[null]147.0005727SE58[null]0Victoria, BC0
2883.158300male[null]137.000PC 17756CE52[null]1Lakewood, NJ1
2926.550000male[null]1[null]113791S[null][null]0Roachdale, IN0
3071.000000male[null]170.000WE/P 5735SB222691Milwaukee, WI1
3171.283300male[null]139.000PC 17599CC85[null]0New York, NY1
3252.000000male[null]131.000F.C. 12750SB71[null]0Montreal, PQ1
33106.425000male[null]150.000PC 17761CC86620Deephaven, MN / Cedar Rapids, IA1
3429.700000male[null]139.000PC 17580CA181330Philadelphia, PA0
3531.679200female[null]136.000PC 17531CA29[null]0New York, NY0
36221.779200male[null]1[null]PC 17483SC95[null]0[null]0
3727.750000male[null]130.000113051CC111[null]0New York, NY0
38263.000000male[null]119.00019950SC23 C25 C27[null]2Winnipeg, MB3
39263.000000male[null]164.00019950SC23 C25 C27[null]4Winnipeg, MB1
4026.550000male[null]1[null]113778SD34[null]0Westcliff-on-Sea, Essex0
410.000000male[null]1[null]112058SB102[null]0[null]0
4253.100000male[null]137.000113803SC123[null]0Scituate, MA1
4338.500000male[null]147.000111320SE632750St Anne's-on-Sea, Lancashire0
4479.200000male[null]124.000PC 17593CB86[null]0[null]0
4534.654200male[null]171.000PC 17754CA5[null]0New York, NY0
46153.462500male[null]138.000PC 17582SC911471Winnipeg, MB0
4779.200000male[null]146.000PC 17593CB82 B84[null]0New York, NY0
4842.400000male[null]1[null]113796S[null][null]0[null]0
4983.475000male[null]145.00036973SC83[null]0New York, NY1
500.000000male[null]140.000112059SB941100[null]0
5193.500000male[null]155.00012749SB693071Montreal, PQ1
5242.500000male[null]142.000113038SB11[null]0London / Middlesex0
5351.862500male[null]1[null]17463SE46[null]0Brighton, MA0
5450.000000male[null]155.000680SC39[null]0London / Birmingham0
5552.000000male[null]142.000113789S[null]380New York, NY1
5630.695800male141[null]PC 17600C[null][null]0New York, NY0
5728.712500female[null]150.000PC 17595CC49[null]0Paris, France New York, NY0
5826.000000male[null]146.000694S[null]800Bennington, VT0
5926.000000male[null]150.000113044SE60[null]0London0
60211.500000male[null]132.500113503CC132450[null]0
6129.700000male[null]158.00011771CB372580Buffalo, NY0
6251.862500male[null]141.00017464SD21[null]0Southington / Noank, CT1
6326.550000male[null]1[null]113028SC124[null]0Portland, OR0
6427.720800male[null]1[null]PC 17612C[null][null]0Chicago, IL0
6530.000000male[null]129.000113501SD61260Springfield, MA0
6645.500000male[null]130.000113801S[null][null]0London / New York, NY0
6726.000000male[null]130.000110469SC106[null]0Brockton, MA0
6853.100000male[null]119.000113773SD30[null]0New York, NY1
6975.241700male[null]146.00013050CC62920Vancouver, BC0
7051.862500male[null]154.00017463SE461750Dorchester, MA0
7182.170800male[null]128.000PC 17604C[null][null]0New York, NY1
7226.550000male[null]165.00013509SE382490East Bridgewater, MA0
7390.000000male[null]144.00019928QC782300Fond du Lac, WI2
7430.500000male[null]155.000113787SC30[null]0Montreal, PQ0
7542.400000male[null]147.000113796S[null][null]0Washington, DC0
7629.700000male[null]137.000PC 17596CC118[null]1Brooklyn, NY0
77113.275000male[null]158.00035273CD481222Lexington, MA0
7826.000000male[null]164.000693S[null]2630Isle of Wight, England0
7961.979200male[null]165.000113509CB302341Providence, RI0
8027.720800male[null]128.500PC 17562CD431890?Havana, Cuba0
810.000000male[null]1[null]112052S[null][null]0Belfast0
8228.500000male[null]145.500113043SC1241660Surbiton Hill, Surrey0
8393.500000male[null]123.00012749SB24[null]0Montreal, PQ0
8466.600000male[null]129.000113776SC2[null]0Isleworth, England1
85108.900000male[null]118.000PC 17758CC65[null]0Madrid, Spain1
8652.000000male[null]147.000110465SC1102070Worcester, MA0
870.000000male[null]138.00019972S[null][null]0Rotterdam, Netherlands0
88135.633300male[null]122.000PC 17760C[null]2320[null]0
89227.525000male[null]1[null]PC 17757C[null][null]0[null]0
9050.495800male[null]131.000PC 17590SA24[null]0Trenton, NJ0
9150.000000male[null]1[null]113767SA32[null]0Seattle, WA0
9240.125000male[null]136.00013049CA10[null]0Winnipeg, MB0
9359.400000male[null]155.000PC 17603C[null][null]0New York, NY1
9426.550000male[null]133.000113790S[null]1090London0
95262.375000male[null]161.000PC 17608CB57 B59 B63 B66[null]3Haverford, PA / Cooperstown, NY1
9655.900000male[null]150.00013507SE44[null]0Duluth, MN1
9726.550000male[null]156.000113792S[null][null]0New York, NY0
9830.695800male[null]156.00017764CA7[null]0St James, Long Island, NY0
9960.000000male[null]124.00013695SC31[null]0Huntington, WV1
10026.000000male[null]1[null]113056SA19[null]0Streatham, Surrey0
Rows: 1-100 of 1234 | Columns: 14
In [98]:
# Doing some transformations
titanic.get_dummies()
titanic.normalize()
123
fare
Float
123
Float
Abc
sex
Varchar(20)
Abc
boat
Varchar(100)
123
pclass
Float
123
age
Float
Abc
ticket
Varchar(36)
Abc
Varchar(164)
Abc
embarked
Varchar(20)
Abc
cabin
Varchar(30)
123
body
Float
123
Float
Abc
home.dest
Varchar(100)
123
Float
123
Float
123
pclass_1
Float
123
Float
123
Float
123
embarked_Q
Float
123
parch_0
Float
123
Float
123
Float
123
Float
123
Float
123
Float
123
Float
123
Float
123
sibsp_1
Float
123
Float
123
Float
123
Float
123
Float
12.2335228377568673306163744003female[null]-1.52458485653939825566284767748-1.9502503129565278908367342155113781SC22 C26[null]Montreal, PQ / Chesterville, ON1.718351957456489070218766430323-0.30642369222116871970059157132-1.824041162431690996888970269341.74835105897043756352888762989
22.2335228377568673306163744003male[null]-1.52458485653939825566284767748-0.0105614239550127329564098413113781SC22 C26-0.30177333429701812091999864Montreal, PQ / Chesterville, ON1.718351957456489070218766430323-0.30642369222116871970059157132-1.824041162431690996888970269341.74835105897043756352888762989
32.2335228377568673306163744003female[null]-1.52458485653939825566284767748-0.3569344398481404397207534796113781SC22 C26[null]Montreal, PQ / Chesterville, ON1.718351957456489070218766430323-0.30642369222116871970059157132-1.824041162431690996888970269341.74835105897043756352888762989
4-0.6451344183800711827483251581male[null]-1.524584856539398255662847677480.6129100046526171392194087075112050SA36[null]Belfast, NI1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
50.2951864297839290254556257484male[null]-1.524584856539398255662847677482.8296973063686344625112079923PC 17609C[null]-1.47183603843091257442431516Montevideo, Uruguay1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
63.6766504196440590399722506719male[null]-1.524584856539398255662847677481.1671068300816214700423585287PC 17757CC62 C64-0.41567324354899014736732149New York, NY1.718351957456489070218766430323-0.306423692221168719700591571320.547788968696555206014856512471.74835105897043756352888762989
7-0.1526950296281732549424535906male[null]-1.52458485653939825566284767748[null]PC 17318S[null][null]New York, NY1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
84.0564660234861111358187558479male[null]-1.52458485653939825566284767748-0.4262090430267659810736222072PC 17558CB58 B60[null]Montreal, PQ1.718351957456489070218766430323-0.30642369222116871970059157132-1.82404116243169099688897026934-0.57150400207205686533461107422
90.7840642993307746538800662293maleA-1.524584856539398255662847677480.405086195116740515160802524613050CC6[null]Winnipeg, MN1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
10-0.1512704219461523351898811560male[null]-1.52458485653939825566284767748-0.356934439848140439720753479613905C[null]-0.16716435063559663511861709San Francisco, CA1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
110.0291798844431641668026272294male[null]-1.524584856539398255662847677481.0285576237243703873366210734113784ST[null]Trenton, NJ1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
12-0.1408232989446655903376833021male[null]-1.524584856539398255662847677480.8207338141884937632780148905110489SD22[null]London / Winnipeg, MB1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
13-0.0657939610248971500355350787male[null]-1.524584856539398255662847677480.7514592110098682219251461628113054SA21[null]Pomeroy, WA1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
140.3140216428171549458109700973male[null]-1.524584856539398255662847677481.2363814332602470113952272564PC 17591CB100.45410788164788714550314389Omaha, NE1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
150.1070584377269744466099203220male[null]-1.52458485653939825566284767748[null]112379C[null][null]Philadelphia, PA1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
16-0.1408232989446655903376833021male[null]-1.524584856539398255662847677481.0285576237243703873366210734113050SB38[null]Washington, DC1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
17-0.0562965764780910183517188479male[null]-1.52458485653939825566284767748[null]113798S[null][null][null]1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
18-0.5501605729120098659101628500male[null]-1.524584856539398255662847677480.1972623855808638911021963416695SB51 B53 B55[null]New York, NY1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
190.2495192059290664218671637842male[null]-1.52458485653939825566284767748-0.1491106303122638156621472966113059S[null][null]Montevideo, Uruguay1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
200.2495192059290664218671637842male[null]-1.52458485653939825566284767748-0.9111312652771447705437033008113059S[null][null]Montevideo, Uruguay1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
21-0.1512704219461523351898811560male[null]-1.524584856539398255662847677481.305656036438872552748095984019924S[null][null]Ascot, Berkshire / Rochester, NY1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
220.8526031246512557837894944406male[null]-1.524584856539398255662847677480.405086195116740515160802524619877SC460.08134454227779687713008730Little Onn Hall, Staffs1.718351957456489070218766430323-0.306423692221168719700591571320.547788968696555206014856512471.74835105897043756352888762989
230.5168705809216590287665906814male[null]-1.524584856539398255662847677481.0978322269029959286894898011W.E.P. 5734SE31[null]Amenia, ND1.718351957456489070218766430323-0.306423692221168719700591571320.547788968696555206014856512471.74835105897043756352888762989
24-0.6451344183800711827483251581male[null]-1.52458485653939825566284767748[null]112051S[null][null]Liverpool, England / Belfast1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
251.9529549024289393108657488362male[null]-1.52458485653939825566284767748-0.218385233490889357015016024313508CC89[null]Los Angeles, CA1.718351957456489070218766430323-0.306423692221168719700591571320.547788968696555206014856512471.74835105897043756352888762989
260.3425935744877665123685628461male[null]-1.52458485653939825566284767748[null]110465SA14[null]Stoughton, MA1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
27-0.1591057641972673938290295464male[null]-1.524584856539398255662847677481.16710683008162147004235852875727SE58[null]Victoria, BC1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
280.9344382883372654980562653750male[null]-1.524584856539398255662847677480.4743607982953660565136712522PC 17756CE52[null]Lakewood, NJ1.718351957456489070218766430323-0.30642369222116871970059157132-1.824041162431690996888970269341.74835105897043756352888762989
29-0.1408232989446655903376833021male[null]-1.52458485653939825566284767748[null]113791S[null][null]Roachdale, IN1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
300.7034941872663995163535796169male[null]-1.524584856539398255662847677482.7604227031900089211583392647WE/P 5735SB221.08573465113609565580193423Milwaukee, WI1.718351957456489070218766430323-0.30642369222116871970059157132-1.824041162431690996888970269341.74835105897043756352888762989
310.7088754053506198705656298932male[null]-1.524584856539398255662847677480.6129100046526171392194087075PC 17599CC85[null]New York, NY1.718351957456489070218766430323-0.306423692221168719700591571320.547788968696555206014856512471.74835105897043756352888762989
320.3425935744877665123685628461male[null]-1.524584856539398255662847677480.0587131792236128083964588863F.C. 12750SB71[null]Montreal, PQ1.718351957456489070218766430323-0.306423692221168719700591571320.547788968696555206014856512471.74835105897043756352888762989
331.3763838824076139461519595697male[null]-1.524584856539398255662847677481.3749306396174980941009647117PC 17761CC86-1.05765455024192338734314117Deephaven, MN / Cedar Rapids, IA1.718351957456489070218766430323-0.306423692221168719700591571320.547788968696555206014856512471.74835105897043756352888762989
34-0.0809897762997869607296410480male[null]-1.524584856539398255662847677480.6129100046526171392194087075PC 17580CA18-0.32248240870646758027405734Philadelphia, PA1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
35-0.0433953293097095690724228800female[null]-1.524584856539398255662847677480.4050861951167405151608025246PC 17531CA29[null]New York, NY1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
363.5675102753859816971145080739male[null]-1.52458485653939825566284767748[null]PC 17483SC95[null][null]1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
37-0.1180295760323308742965243482male[null]-1.52458485653939825566284767748-0.0105614239550127329564098413113051CC111[null]New York, NY1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
384.3504898532399540829390122478male[null]-1.52458485653939825566284767748-0.772582058919893687837965845519950SC23 C25 C27[null]Winnipeg, MB1.718351957456489070218766430323-0.30642369222116871970059157132-1.82404116243169099688897026934-0.57150400207205686533461107422
394.3504898532399540829390122478male[null]-1.524584856539398255662847677482.344775084118255673041126898819950SC23 C25 C27[null]Winnipeg, MB1.718351957456489070218766430323-0.30642369222116871970059157132-1.824041162431690996888970269341.74835105897043756352888762989
40-0.1408232989446655903376833021male[null]-1.52458485653939825566284767748[null]113778SD34[null]Westcliff-on-Sea, Essex1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
41-0.6451344183800711827483251581male[null]-1.52458485653939825566284767748[null]112058SB102[null][null]1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
420.3634878204907400020729585539male[null]-1.524584856539398255662847677480.4743607982953660565136712522113803SC123[null]Scituate, MA1.718351957456489070218766430323-0.306423692221168719700591571320.547788968696555206014856512471.74835105897043756352888762989
430.0861641917240009569055246142male[null]-1.524584856539398255662847677481.1671068300816214700423585287111320SE631.14786187436444403386411033St Anne's-on-Sea, Lancashire1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
440.8592512938340200759681658021male[null]-1.52458485653939825566284767748-0.4262090430267659810736222072PC 17593CB86[null][null]1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
450.0131141087437869144462836933male[null]-1.524584856539398255662847677482.8296973063686344625112079923PC 17754CA5[null]New York, NY1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
462.2698503336484007843069714832male[null]-1.524584856539398255662847677480.5436354014739915978665399799PC 17582SC91-0.17751888784032136479564644Winnipeg, MB1.718351957456489070218766430323-0.30642369222116871970059157132-1.82404116243169099688897026934-0.57150400207205686533461107422
470.8592512938340200759681658021male[null]-1.524584856539398255662847677481.0978322269029959286894898011PC 17593CB82 B84[null]New York, NY1.718351957456489070218766430323-0.306423692221168719700591571320.54778896869655520601485651247-0.57150400207205686533461107422
480.1602437911890887840392912145male[null]-1.52458485653939825566284767748[null]113796