Create example.txt
Browse files- example.txt +75 -0
example.txt
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
###Instruction: Generate a small python repo for matplotlib to visualize timeseries data to read from timeseries.csv file using polars.
|
2 |
+
###Response: The repository should include the following:
|
3 |
+
- A `src` directory for the Python source files.
|
4 |
+
- A `data` directory for the input CSV file.
|
5 |
+
- A `requirements.txt` file listing the necessary libraries.
|
6 |
+
- A `README.md` file explaining how to use the tool.
|
7 |
+
- A `run.sh` script to execute the main program.
|
8 |
+
|
9 |
+
Create the repository structure and populate it with the necessary files. ```python
|
10 |
+
<libs>matplotlib,polars</libs>
|
11 |
+
<planning>
|
12 |
+
#1 Create the repository structure.
|
13 |
+
- Initialize the git repository.
|
14 |
+
- Create the `src`, `data`, and `docs` directories.
|
15 |
+
#2 Populate the repository with necessary files.
|
16 |
+
- Add a `requirements.txt` file with the necessary libraries.
|
17 |
+
- Add a `README.md` file explaining how to use the tool.
|
18 |
+
- Add a `run.sh` script to execute the main program.
|
19 |
+
- Add a Python script in `src` to visualize timeseries data.
|
20 |
+
</planning>
|
21 |
+
<requirements>matplotlib==3.5.1
|
22 |
+
polars==0.17.0</requirements>
|
23 |
+
<output><file1>src/visualize_timeseries.py<content>
|
24 |
+
import polars as pl
|
25 |
+
import matplotlib.pyplot as plt
|
26 |
+
|
27 |
+
def load_timeseries_data(file_path):
|
28 |
+
"""Load timeseries data from a CSV file."""
|
29 |
+
return pl.read_csv(file_path, has_headers=True)
|
30 |
+
|
31 |
+
def visualize_timeseries(data):
|
32 |
+
"""Visualize the timeseries data."""
|
33 |
+
plt.figure(figsize=(10, 6))
|
34 |
+
plt.plot(data['timestamp'], data['value'], label='Timeseries Data')
|
35 |
+
plt.xlabel('Timestamp')
|
36 |
+
plt.ylabel('Value')
|
37 |
+
plt.title('Timeseries Visualization')
|
38 |
+
plt.legend()
|
39 |
+
plt.grid(True)
|
40 |
+
plt.show()
|
41 |
+
|
42 |
+
if __name__ == "__main__":
|
43 |
+
file_path = 'data/timeseries.csv'
|
44 |
+
data = load_timeseries_data(file_path)
|
45 |
+
visualize_timeseries(data)
|
46 |
+
</content></file1>
|
47 |
+
<bashfile>run.sh<content>python3 src/visualize_timeseries.py</content></bashfile>
|
48 |
+
<readme>README.md<content>
|
49 |
+
# Timeseries Visualization Tool
|
50 |
+
|
51 |
+
This tool visualizes timeseries data loaded from a CSV file using `pandas` for data handling and `matplotlib` for plotting.
|
52 |
+
|
53 |
+
## Requirements
|
54 |
+
|
55 |
+
Ensure you have the following libraries installed:
|
56 |
+
|
57 |
+
```bash
|
58 |
+
pip install -r requirements.txt
|
59 |
+
```
|
60 |
+
|
61 |
+
## Usage
|
62 |
+
|
63 |
+
To run the visualization tool, execute the following command:
|
64 |
+
|
65 |
+
```bash
|
66 |
+
bash run.sh
|
67 |
+
```
|
68 |
+
|
69 |
+
## Data
|
70 |
+
|
71 |
+
The tool expects a CSV file named `timeseries.csv` in the `data` directory with the following columns:
|
72 |
+
- `timestamp`: Timestamp of the data point.
|
73 |
+
- `value`: Value of the timeseries data.
|
74 |
+
</content></readme>
|
75 |
+
</output>
|