File size: 2,504 Bytes
2ff5974
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
###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>