“PANDAS Menulis CSV” Kode Jawaban

kode bagaimana panda menyimpan file csv

df.to_csv('out.csv')
Gifted Gerbil

DataFrame ke CSV Python

import pandas as pd

# Dataframe example
df = pd.DataFrame({'col_A':[1,5,7,8],'col_B':[9,7,4,3]})

# Save dataframe as csv file in the current folder
df.to_csv('filename.csv', index = False, encoding='utf-8') # False: not include index
print(df)

#Note: to Save dataframe as csv file in other folder use instead:

''' 
df.to_csv('Path/filename.csv', index = False, encoding='utf-8') # Replace 'Path' by the wanted folder
''';

Gabriel Juri

Tulis DataFrame ke CSV Python

df.to_csv (r'C:\Users\John\Desktop\export_dataframe.csv', index = None, header=True) 
Clear Copperhead

DF ke CSV

df.to_csv(file_name, encoding='utf-8', index=False)
Cheerful Constrictor

indeks drop to_csv

df.to_csv('file.csv', index=False)
nomjeeb

PANDAS Menulis CSV

from pathlib import Path  
>>> filepath = Path('folder/subfolder/out.csv')  
>>> filepath.parent.mkdir(parents=True, exist_ok=True)  
>>> df.to_csv(filepath)
Anna Nguyen

Jawaban yang mirip dengan “PANDAS Menulis CSV”

Pertanyaan yang mirip dengan “PANDAS Menulis CSV”

Lebih banyak jawaban terkait untuk “PANDAS Menulis CSV” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya