-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurlciever
38 lines (32 loc) · 874 Bytes
/
urlciever
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
import os
import sys
import json
import requests
import numpy as np
import pandas as pd
from datetime import datetime
def get_data(url):
response = requests.get(url)
data = json.loads(response.text)
return data
def process_data(data):
df = pd.DataFrame(data)
df['timestamp'] = pd.to_datetime(df['timestamp'])
df = df.set_index('timestamp')
return df
def analyze_data(df):
mean = df['value'].mean()
std = df['value'].std()
return mean, std
def save_results(mean, std):
with open('results.txt', 'w') as f:
f.write(f'Mean: {mean}\nStandard deviation: {std}')
def main():
url = 'https://example.com/data.json'
data = get_data(url)
df = process_data(data)
mean, std = analyze_data(df)
save_results(mean, std)
print(f'Mean: {mean}\nStandard deviation: {std}')
if __name__ == '__main__':
main()