To save a .parquet
file with Python, you can use the pandas library, which provides a convenient way to read and write data in a variety of formats, including Parquet.
Let me share with you an example:
```Python import pandas as pd
create a sample DataFrame
data = {'name': ['Alice', 'Bob', 'Charlie'], 'age': [25, 30, 35], 'city': ['New York', 'San Francisco', 'Seattle']} df = pd.DataFrame(data)
Save the DataFrame as a Parquet file
df.to_parquet('example.parquet')
In this example, I first created a sample DataFrame using a Python dictionary an calling it data
Then use the to_parquet()
method -- as part of pandas -- to save the DataFrame as a Parquet file.
Note: The file will be saved in the current working directory with the name
example.parquet
.
- you can change the name of the file from
example
tomy_data_frame
- you can change the directory to save this file by adding
folder/subfolder/example.parquet
- you can also change the directory using
os