D
D
denislysenko2021-09-29 12:24:08
Python
denislysenko, 2021-09-29 12:24:08

How to change csv file to parquet file?

I wrote two functions. The functions take two arguments: the name of the file that is in the same directory as the script itself, and the name of the file it should be changed to. These two functions do not work. Where is the mistake?

import pandas as pd

# csv_to_parquet
def csv_to_parquet(src_filename, dst_filename):
    df = pd.read_csv(src_filename)
    df.to_parquet(dst_filename)

# parquet_to_csv
def parquet_to_csv(src_filename, dst_filename):
    df = pd.read_parquet(src_filename)
    df.to_csv(dst_filename)

csv_to_parquet(example.csv, example123.parquet)
parquet_to_csv(example123.parquet, example.csv)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question