testing
Belo this will be the start of the included html contents
#%% #%% arr = [1, 2, 3, 4, 5, 6] num = 7 def summer(arr, num): idx = 0 for i in range(len(arr)-1): for j in range(i+1, len(arr)): if arr[i] + arr[j] == num: print(i, j) summer(arr, num) #%% import requests import json def authenticate_user(username, password): auth_url = "https://api.spaceandtime.io/v1/user/authenticate" headers = { "Content-Type": "application/json" } data = { "username": username, "password": password } response = requests.post(auth_url, headers=headers, data=json.dumps(data)) if response.status_code == 200: token = response.json()["token"] return token else: raise Exception("Failed to authenticate user") #%% pip install cufflinks #%% import cufflinks as cf cf.go_offline() #%% import seaborn as sns iris = sns.load_dataset('iris') #%% iris[['sepal_length', 'sepal_width']].iplot(kind='scatter', mode='markers') #%% import pandas as pd import numpy as np # Create a sample dataset dates = pd.date_range('2023-01-01', '2023-02-28') prices = np.random.randint(100, 200, len(dates)) volumes = np.random.randint(10000, 50000, len(dates)) df = pd.DataFrame({'date': dates, 'open': prices, 'high': prices + 10, 'low': prices - 10, 'close': prices, 'volume': volumes}) # Save the dataset to a CSV file df.to_csv('sample_data.csv', index=False) #%% import pandas as pd import cufflinks as cf from plotly.offline import iplot from plotly.subplots import make_subplots # Load data from CSV file into a Pandas dataframe df = pd.read_csv('sample_data.csv') # Convert datetime column to a Pandas datetime format df['date'] = pd.to_datetime(df['date']) # Resample data to daily frequency and aggregate using OHLC df = df.set_index('date').resample('D').agg({'open': 'first', 'high': 'max', 'low': 'min', 'close': 'last', 'volume': 'sum'}) # Create a subplots object with two rows and one column fig = make_subplots(rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.02) # Add a Candlestick chart to the top row fig.add_trace( cf.Candlestick( x=df.index, open=df['open'], high=df['high'], low=df['low'], close=df['close'] ), row=1, col=1 ) # Add a Volume bar chart to the bottom row fig.add_trace( cf.Bar( x=df.index, y=df['volume'], opacity=0.5 ), row=2, col=1 ) # Set the chart layout fig.update_layout( title='Stock Price', yaxis=dict(title='Price'), yaxis2=dict(title='Volume', overlaying='y', side='right'), xaxis_rangeslider_visible=False ) # Show the chart iplot(fig) #%% import pandas as pd import requests from io import StringIO # Download gene expression data from GEO database url = 'https://www.ncbi.nlm.nih.gov/geo/download/?acc=GSE100186&format=file&file=GSE100186%5Fraw%5Fdata%2Etxt%2Egz' r = requests.get(url) # Decompress the downloaded data and load it into a Pandas dataframe data = StringIO(r.content.decode('utf-8')) df = pd.read_csv(data, delimiter='\t') # Drop columns that are not gene expression data df = df.drop(['ID_REF', 'VALUE', 'detection p-value'], axis=1) # Transpose the dataframe so that genes are rows and samples are columns df = df.transpose() # Rename the columns to sample names df.columns = df.iloc[0] df = df.drop('IDENTIFIER') # Save the dataframe to a CSV file df.to_csv('gene_expression_data.csv') #%% import pandas as pd import requests from io import StringIO # Download gene expression data from GEO database url = 'https://www.ncbi.nlm.nih.gov/geo/download/?acc=GSE100186&format=file&file=GSE100186%5Fraw%5Fdata%2Etxt%2Egz' r = requests.get(url) # Decompress the downloaded data and load it into a Pandas dataframe data = StringIO(r.content.decode('utf-8')) df = pd.read_csv(data, delimiter='\t') # Drop columns that contain gene expression data df = df.drop(['CONTROL_TYPE', 'CONTROL_TYPE_DESCRIPTION'], axis=1) # Transpose the dataframe so that genes are rows and samples are columns df = df.transpose() # Rename the columns to sample names df.columns = df.iloc[0] df = df.drop('IDENTIFIER') # Save the dataframe to a CSV file df.to_csv('gene_expression_data.csv') #%% import pandas as pd import requests from io import StringIO # Download gene expression data from GEO database url = 'https://www.ncbi.nlm.nih.gov/geo/download/?acc=GSE100186&format=file&file=GSE100186%5Fraw%5Fdata%2Etxt%2Egz' r = requests.get(url) # Decompress the downloaded data and load it into a Pandas dataframe data = StringIO(r.content.decode('utf-8')) df = pd.read_csv(data, delimiter='\t') # Drop irrelevant columns df = df.drop(['INDEX', 'GENE_SYMBOL'], axis=1) # Transpose the dataframe so that genes are rows and samples are columns df = df.transpose() # Rename the columns to sample names df.columns = df.iloc[0] df = df.drop('IDENTIFIER') # Save the dataframe to a CSV file df.to_csv('gene_expression_data.csv') #%%
Written on March 3, 2023