local-repo-coder-v0 / example.txt
reshinthadith's picture
Create example.txt
2ff5974 verified
###Instruction: Generate a small python repo for matplotlib to visualize timeseries data to read from timeseries.csv file using polars.
###Response: The repository should include the following:
- A `src` directory for the Python source files.
- A `data` directory for the input CSV file.
- A `requirements.txt` file listing the necessary libraries.
- A `README.md` file explaining how to use the tool.
- A `run.sh` script to execute the main program.
Create the repository structure and populate it with the necessary files. ```python
<libs>matplotlib,polars</libs>
<planning>
#1 Create the repository structure.
- Initialize the git repository.
- Create the `src`, `data`, and `docs` directories.
#2 Populate the repository with necessary files.
- Add a `requirements.txt` file with the necessary libraries.
- Add a `README.md` file explaining how to use the tool.
- Add a `run.sh` script to execute the main program.
- Add a Python script in `src` to visualize timeseries data.
</planning>
<requirements>matplotlib==3.5.1
polars==0.17.0</requirements>
<output><file1>src/visualize_timeseries.py<content>
import polars as pl
import matplotlib.pyplot as plt
def load_timeseries_data(file_path):
"""Load timeseries data from a CSV file."""
return pl.read_csv(file_path, has_headers=True)
def visualize_timeseries(data):
"""Visualize the timeseries data."""
plt.figure(figsize=(10, 6))
plt.plot(data['timestamp'], data['value'], label='Timeseries Data')
plt.xlabel('Timestamp')
plt.ylabel('Value')
plt.title('Timeseries Visualization')
plt.legend()
plt.grid(True)
plt.show()
if __name__ == "__main__":
file_path = 'data/timeseries.csv'
data = load_timeseries_data(file_path)
visualize_timeseries(data)
</content></file1>
<bashfile>run.sh<content>python3 src/visualize_timeseries.py</content></bashfile>
<readme>README.md<content>
# Timeseries Visualization Tool
This tool visualizes timeseries data loaded from a CSV file using `pandas` for data handling and `matplotlib` for plotting.
## Requirements
Ensure you have the following libraries installed:
```bash
pip install -r requirements.txt
```
## Usage
To run the visualization tool, execute the following command:
```bash
bash run.sh
```
## Data
The tool expects a CSV file named `timeseries.csv` in the `data` directory with the following columns:
- `timestamp`: Timestamp of the data point.
- `value`: Value of the timeseries data.
</content></readme>
</output>