Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
8,600 | <ASSISTANT_TASK:>
Python Code:
!pip install -q tensorflow_text
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import os
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text as text
from tensorflow import keras
label_ma... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Imports
Step2: Define a label map
Step3: Collect the dataset
Step4: Read the dataset and apply basic preprocessing
Step5: The columns we are... |
8,601 | <ASSISTANT_TASK:>
Python Code:
# standard imports
funcs = pyspark.sql.functions
types = pyspark.sql.types
sqlContext.sql("set spark.sql.shuffle.partitions=32")
bike = spark.read.parquet('/data/citibike.parquet')
bike.registerTempTable('bike')
spark.sql('select * from bike limit 5').toPandas()
bike = (bike
.withCol... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Convert and repartition Subway Dataframe using PySpark
Step2: Convert, repartition, and sort Taxi Dataframe using PySpark
Step3: Using Dask, R... |
8,602 | <ASSISTANT_TASK:>
Python Code:
from keras.models import Sequential
from keras.layers import Conv2D, ZeroPadding2D, Activation, Input, concatenate
from keras.models import Model
from keras.layers.normalization import BatchNormalization
from keras.layers.pooling import MaxPooling2D, AveragePooling2D
from keras.layers.mer... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 0 - Naive Face Verification
Step3: Expected Output
Step4: Expected Output
Step5: Here're some examples of distances between the encodings be... |
8,603 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TPU の使用
Step2: TPU の初期化
Step3: 手動でデバイスを配置する
Step4: 分散ストラテジー
Step5: 計算を複製してすべての TPU コアで実行できるようにするには、計算を strategy.run API に渡します。次の例では、すべてのコアが同... |
8,604 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
vals = np.random.standard_normal(100000)
len(vals)
fig, ax = plt.subplots(1,1)
hist_vals = ax.hist(vals, bins=200, color='red', density=True)
import scipy.stats as st
# compute the p value for a z score
st.norm.cdf(-1.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The above is the standard normal distribution. Its mean is 0 and SD is 1. About 95% values fall within $\mu \pm 2 SD$ and 98% within $\mu \pm 3 ... |
8,605 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Policies
Step2: Python Policies
Step3: The most important method is action(time_step) which maps a time_step containing an observation from th... |
8,606 | <ASSISTANT_TASK:>
Python Code:
%dotobjs S_rca[2].simplify(), S_ksa[2].simplify()
f = Xor(S_rca[9], S_ksa[9])
%timeit f.satisfy_one()
g = f.tseitin()
%timeit g.satisfy_one()
assert f.satisfy_one() is None and g.satisfy_one() is None
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: If XOR(f, g) is UNSAT, functions f and g are equivalent.
Step2: Let's see if we can do better using the Tseitin transformation,
Step3: Success... |
8,607 | <ASSISTANT_TASK:>
Python Code:
import larch
import pandas
from larch.roles import P,X
from larch import data_warehouse
raw = pandas.read_csv(larch.data_warehouse.example_file('swissmetro.csv.gz'))
raw.head()
raw['SM_COST'] = raw['SM_CO'] * (raw["GA"]==0)
raw['TRAIN_COST'] = raw.eval("TRAIN_CO * (GA == 0)")
raw['... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The swissmetro dataset used in this example is conveniently bundled with Larch,
Step2: We can inspect a few rows of data to see what we have us... |
8,608 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import make_regression
from sklearn.cross_validation import train_test_split
X, y, true_coefficient = make_regression(n_samples=80, n_features=30, n_informative=10, noise=100, coef=True, random_state=5)
X_train, X_test, y_train, y_test = train_test_split(X, y, random... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Linear Regression
Step2: Ridge Regression (L2 penalty)
Step3: Lasso (L1 penalty)
Step4: Linear models for classification
Step5: Multi-Class ... |
8,609 | <ASSISTANT_TASK:>
Python Code:
from kubernetes import client, config
config.load_kube_config()
apps_api = client.AppsV1Api()
deployment = client.V1Deployment()
deployment.api_version = "apps/v1"
deployment.kind = "Deployment"
deployment.metadata = client.V1ObjectMeta(name="nginx-deployment")
spec = client.V1Deploym... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load config from default location
Step2: Create Deployment object
Step3: Fill required Deployment fields (apiVersion, kind, and metadata)
Step... |
8,610 | <ASSISTANT_TASK:>
Python Code:
# 単純な2次元のデータセットを生成する
from sklearn.datasets import make_blobs
X, y = make_blobs(n_samples=150, # サンプル点の総数
n_features=2, # 特徴量の個数
centers=3, # クラスタの個数
cluster_std=0.5, # クラスタ内の標準偏差
shuffle=True, # サンプルをシャッ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: k-means法の手続き
Step2: 11.1.1 k-means++ 法
Step3: 11.1.2 ハードクラスタリングとソフトクラスタリング
Step4: 11.1.4 シルエット図を使ってクラスタリングの性能を数値化する
Step5: 11.2 クラスタを階層木として構... |
8,611 | <ASSISTANT_TASK:>
Python Code:
overlay_test(rule_18.get_spacetime(),rule_18.get_spacetime(),t_max=20, x_max=20, text_color='red')
overlay_test(rule_18.get_spacetime(),rule_18.get_spacetime(),t_max=20, x_max=20, colors=plt.cm.Set2, text_color='black')
overlay_test(rule_18.get_spacetime(),rule_18.get_spacetime(),t_max=20... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Tests overlaying inferred states on top of rule 18 spacetime diagram
|
8,612 | <ASSISTANT_TASK:>
Python Code:
from revscoring.extractors import api
import mwapi
extractor = api.Extractor(mwapi.Session("https://en.wikipedia.org",
user_agent="Revscoring feature demo ahalfaker@wikimedia.org"))
from revscoring.features import wikitext
list(extractor.extract(12... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Extract features
Step2: Defining a custom feature
Step3: There's easier ways that we can do this though. revscoring.Feature overloads simple ... |
8,613 | <ASSISTANT_TASK:>
Python Code:
from IPython.core.display import Image
Image("http://upload.wikimedia.org/wikipedia/commons/thumb/2/28/IEC60825_MPE_W_s.png/640px-IEC60825_MPE_W_s.png")
####
# Parámetros a modificar. INICIO
####
filename = "http://www.semrock.com/_ProductData/Spectra/NF01-229_244_DesignSpectrum.txt"
# P... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Tarea 1 (a). Irradiancia máxima
|
8,614 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
# Size of the points dataset.
m = 20
# Points x-coordinate and dummy value (x0, x1).
X0 = np.ones((m, 1))
X1 = np.arange(1, m+1).reshape(m, 1)
X = np.hstack((X0, X1))
# Points y-coordinate
y = np.array([3, 4, 5, 5, 2, 4, 7, 8, 11, 8, 12,
11, 13, 13, 16, 17, 18, 17, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This is the End!
Step3: For many functions it’s easy to exactly calculate derivatives.
Step4: When f is a function of many variables, it has ... |
8,615 | <ASSISTANT_TASK:>
Python Code:
print(__doc__)
from sklearn.cluster import AffinityPropagation
from sklearn import metrics
from sklearn.datasets.samples_generator import make_blobs
centers = [[1, 1], [-1, -1], [1, -1]]
X, labels_true = make_blobs(n_samples=300, centers=centers, cluster_std=0.5,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generate sample data
Step2: Compute Affinity Propagation
Step3: Plot result
|
8,616 | <ASSISTANT_TASK:>
Python Code:
!pip install tensorflow-hub
!pip install tensorflow-datasets
import os
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_datasets as tfds
print("Version: ", tf.__version__)
print("Eager mode: ", tf.executing_eagerly())
print("Hub version: ", hub.__v... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download the IMDB dataset
Step2: Explore the data
Step3: Let's also print the first 10 labels.
Step4: Build the model
Step5: Let's now build... |
8,617 | <ASSISTANT_TASK:>
Python Code:
!wget https://ndownloader.figshare.com/files/3686778 -P data/
%%capture
!unzip data/3686778 -d data/
%matplotlib inline
import numpy as np
from datascience import *
with open('data/Augustine-Confessions.txt') as f:
confessions = f.read()
confessions
confessions_list = confessions.s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Bag of Words (BoW) language model
Step2: Let's read in Augustine's Confessions text
Step3: There should be 13 books, which are fortunately sep... |
8,618 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mri', 'sandbox-2', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,619 | <ASSISTANT_TASK:>
Python Code:
import nltk
# You only need to run this cell once.
# After that, you can comment it out.
nltk.download('vader_lexicon', quiet=False)
from nltk.sentiment import vader
from nltk.sentiment.vader import SentimentIntensityAnalyzer
vader_model = SentimentIntensityAnalyzer()
sentences = ["Her... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To verify that the download was successful, you can run the following command.
Step2: 2. Load VADER model
Step3: We will use the following thr... |
8,620 | <ASSISTANT_TASK:>
Python Code:
cd ..
%run check_test_score.py -v run_settings/alexnet_based_norm_global.json
%run check_test_score.py -v run_settings/alexnet_learning_rate.json
%matplotlib inline
%run ~/Neuroglycerin/pylearn2/pylearn2/scripts/plot_monitor.py /disk/scratch/neuroglycerin/models/alexnet_based_norm_globa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Just to make sure nothing goes wrong with reads/writes (as this model takes a lot less time per epoch), get a backup of the best model so far.
S... |
8,621 | <ASSISTANT_TASK:>
Python Code:
import os
# The Vertex AI Workbench Notebook product has specific requirements
IS_WORKBENCH_NOTEBOOK = os.getenv("DL_ANACONDA_HOME")
IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(
"/opt/deeplearning/metadata/env_version"
)
# Vertex AI Notebook requires dependencies to be install... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Restart the kernel
Step2: Set up your Google Cloud project
Step3: Otherwise, set your project ID here.
Step4: Region
Step5: Timestamp
Step6:... |
8,622 | <ASSISTANT_TASK:>
Python Code:
import calour as ca
ca.set_log_level(11)
%matplotlib notebook
cfs=ca.read_amplicon('data/chronic-fatigue-syndrome.biom',
'data/chronic-fatigue-syndrome.sample.txt',
normalize=10000,min_reads=1000)
print(cfs)
movpic=ca.read_amplicon('data/moving_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the data
Step2: Moving pictures dataset. from
Step3: sorting the samples based on a metadata field (sort_samples)
Step4: and is the new ... |
8,623 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function # only necessary if using Python 2.x
import matplotlib.pyplot as plt
import numpy as np
import pyshtools
degrees = np.arange(101, dtype=float)
degrees[0] = np.inf
power = degrees**(-2)
clm = pyshtools.SHCoeffs.from_random(power)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The pyshtools module contains the three classes SHCoeffs, SHGrid, and SHWindow, a submodule shtools that contains all of the Python-wrapped Fort... |
8,624 | <ASSISTANT_TASK:>
Python Code:
import sklearn
import numpy as np
import matplotlib.pyplot as plt
data = np.array([[1,2], [2,3], [3,4], [4,5], [5,6]])
x = data[:,0]
y = data[:,1]
data, x, y
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer(min_df = 1)
content = ["How to format my ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Text processing with Scikit learn
Step2: Array vector for the first document
Step3: Number of times word "hard" occurs
Step4: Using the 20 Ne... |
8,625 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from lightfm.datasets import fetch_stackexchange
from polara.recommender.coldstart.data import ItemColdStartData
from polara.tools.display import print_frames # to print df's side-by-side
data = fetch_stackexchange('crossvalidated',
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The data variable contains both training and test datasets, as well as tag assignments and their labels
Step2: Now, we need to convert it into ... |
8,626 | <ASSISTANT_TASK:>
Python Code:
# Author: Tommy Clausner <tommy.clausner@gmail.com>
#
# License: BSD (3-clause)
import os
import mne
from mne.datasets import sample
print(__doc__)
sample_dir_raw = sample.data_path()
sample_dir = os.path.join(sample_dir_raw, 'MEG', 'sample')
subjects_dir = os.path.join(sample_dir_raw, '... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Setup paths
Step2: Load example data
Step3: Setting up SourceMorph for SourceEstimate
Step4: Apply morph to (Vector) SourceEstimate
Step5: P... |
8,627 | <ASSISTANT_TASK:>
Python Code:
excel_filepath = ""
csv_output_filepath = ""
import pandas
file = pandas.read_excel(excel_filepath)
file = file.rename_axis({'NAME':'Name', 'TIME1':'Time', 'WEATHER1':'Weather', 'TEMPERATURE1':'Temperature'}, 1)
data = file[['ID', 'Name', 'Time', 'Weather', 'Temperature']].sort_values(b... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import statements
Step2: Compute site visits
Step3: Export to csv
|
8,628 | <ASSISTANT_TASK:>
Python Code:
%config InlineBackend.figure_format = 'retina'
%matplotlib inline
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('white')
import pandas as pd
# Load data
df = pd.DataFrame.from_csv('./posterviewers_by_state.csv')
key_N = 'Number o... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Summarize data by state
Step2: 2. Poster popularity vs. prevalence
Step3: 3. Permutation tests
|
8,629 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy.sparse.linalg as sp
import sympy as sym
from scipy.linalg import toeplitz
import ipywidgets as widgets
from ipywidgets import IntSlider
import matplotlib.pyplot as plt
%matplotlib inline
from matplotlib import cm
from matplotlib.ticker import LinearLocator,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First algorithm
Step2: Second algorithm
Step3: Third algorithm
Step4: 8.2 Stochastic predator-prey model
|
8,630 | <ASSISTANT_TASK:>
Python Code:
pythonString = "Hello From Python"
pythonInt = 20
import pixiedust
%%scala
print(pythonString)
print(pythonInt + 10)
%%scala
//Reuse the sqlContext object available in the python scope
val c = sqlContext.asInstanceOf[org.apache.spark.sql.SQLContext]
import c.implicits._
val __dfFromSca... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import pixiedust module
Step2: Use the python variable in Scala code
Step3: Define a variable in Scala and use it in Python
Step4: Invoke Pix... |
8,631 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import SVG
SVG('img/intro_fig1.svg')
from IPython.display import SVG
SVG('img/intro_fig2.svg')
from IPython.display import SVG
SVG('img/intro_fig3.svg')
from IPython.display import SVG
SVG('img/intro_fig4.svg')
from IPython.display import SVG
SVG('img/intro_fig5.s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Almost every aspect of everyday life is affected by some kind of control system.
Step2: Example
Step3: Uses feedback from the output to the in... |
8,632 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'inm', 'sandbox-3', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,633 | <ASSISTANT_TASK:>
Python Code:
%matplotlib
import numpy as np
import matplotlib.pyplot as plt
# To get interactive plotting (otherwise you need to
# type plt.show() at the end of the plotting commands)
plt.ion()
x = np.linspace(0, 10)
y = np.sin(x)
# basic X/Y line plotting with '--' dashed line and linewidth of 2
pl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Proper use of Matplotlib
Step2: Add a cruve with a title to the plot
Step3: A long list of markers can be found at http
Step4: Add a labels t... |
8,634 | <ASSISTANT_TASK:>
Python Code:
import numpy
X = numpy.array([[1, 2], [1, 4], [1, 0], [4, 2], [4, 4], [4, 0]])
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=2, random_state=0)
kmeans.fit(X)
print(kmeans.labels_)
print(kmeans.predict([[0, 0], [4, 4]]))
print(kmeans.cluster_centers_)
from sklearn.neig... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To use the K-means clustering algorithm from Scikit-learn, we import it and specify the number of clusters (that is the k), and the random state... |
8,635 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Get started with qsimcirq
Step2: Simulating Cirq circuits with qsim is easy
Step3: To sample from this state, you can invoke Cirq's sample_sta... |
8,636 | <ASSISTANT_TASK:>
Python Code:
dict = {'county': ['Cochice', 'Pima', 'Santa Cruz', 'Maricopa', 'Yuma'],
'year': [2012, 2012, 2013, 2014, 2014],
'fireReports': [4, 24, 31, 2, 3]}
# Create a list of keys
list(dict.keys())
# Create a list of values
list(dict.values())
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create a list from the dictionary keys
Step2: Create a list from the dictionary values
|
8,637 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'miroc', 'nicam16-8s', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,638 | <ASSISTANT_TASK:>
Python Code:
from cartoframes.auth import set_default_credentials
set_default_credentials('creds.json')
from cartoframes.data.observatory import Enrichment
from cartoframes.data.services import Geocoding, Isolines
import pandas as pd
stores_df = pd.read_csv('http://libs.cartocdn.com/cartoframes/files... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Enrich your data
Step2: 3. Create a visualization
Step3: 4. Share your visualization
|
8,639 | <ASSISTANT_TASK:>
Python Code:
%%bash
ls -tralFh /root/project/doc/el_camino_north.bag
%%bash
# same size, no worries, just the -h (human) formating differs in rounding
hdfs dfs -ls -h
%%time
out = !java -jar ../lib/rosbaginputformat.jar -f /root/project/doc/el_camino_north.bag
%%bash
ls -tralFh /root/project/doc/el_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Show that the we can read the index
Step2: Create the Spark Session or get an existing one
Step3: Create an RDD from the Rosbag file
|
8,640 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plots
import seaborn as sns # for pretty plots
from scipy.stats import norm
mu,sigma = 0,1
linespace = np.linspace(-6,6,1000)
plots.plot(linespace, norm.pdf(linespace, loc=mu, scale=sigma))
plots.show()
# As have bee... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The samples will be token from a normal distribution and they will be used to train the neural network.
Step2: Now, in this step we are going t... |
8,641 | <ASSISTANT_TASK:>
Python Code:
from functions import connect, touch, forward, backward, stop, disconnect, next_notebook
from time import sleep
connect()
if touch():
backward()
sleep(0.2)
stop()
else:
forward()
sleep(0.2)
stop()
while not touch():
forward()
stop()
disconnect()
next_notebo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: El codi següent comprova el sensor de tacte
Step2: <img src="img/While-loop-diagram.svg.png" align="right">
Step3: Sembla complicat? Les ordre... |
8,642 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import wavfile
import IPython.display as ipd
from ipywidgets import interactive
import ipywidgets as widgets
# plotting options
font = {'size' : 20}
plt.rc('font', **font)
plt.rc('text... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load wave file and convert to mono if stereo
Step2: Uniform Quantization. The quantizer is given by
|
8,643 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import matplotlib.pyplot as plt
from desispec.io.util import write_bintable, makepath
from desisim.io import write_templates
from desisim.archetypes import compute_chi2, ArcheTypes
import multiprocessing
nproc = multiprocessing.cpu_count() // 2
plt.style.use(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Initialize the random seed so the results are reproducible, below.
Step2: Output path and filenames.
Step6: Read the BGS basis templates.
Step... |
8,644 | <ASSISTANT_TASK:>
Python Code:
%%bash
sudo apt-get update -y
sudo apt-get install -y imagemagick
%%bash
convert -resize 10% ../mldp_cover.png logo_small.png
convert -resize 25% ../mldp_cover.png logo_medium.png
# convert -resize 65% ../mldp_cover.png -bordercolor green -border 5 logo_large.png
convert -resize 180% ../m... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: interactions diagram
|
8,645 | <ASSISTANT_TASK:>
Python Code:
help('learning_lab.03_interface_configuration')
from importlib import import_module
script = import_module('learning_lab.03_interface_configuration')
from inspect import getsource
print(getsource(script.main))
print(getsource(script.demonstrate))
run ../learning_lab/03_interface_configu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Implementation
Step2: Execution
Step3: HTTP
|
8,646 | <ASSISTANT_TASK:>
Python Code:
# imports
import requests
import zipfile
import os
# Methods to pull from google drive
def download_file_from_google_drive(id, destination):
URL = "https://docs.google.com/uc?export=download"
session = requests.Session()
response = session.get(URL, params = { 'id' : id }, str... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Methods
Step2: Parameters to pass to Google Drive
Step3: Unzip the data to a directory
|
8,647 | <ASSISTANT_TASK:>
Python Code:
from matplotlib import pyplot as plt
import math
import numpy as np
import os
import pandas as pd
import random
import time
import cntk as C
try:
from urllib.request import urlretrieve
except ImportError:
from urllib import urlretrieve
%matplotlib inline
# to make things reproduce... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In the block below, we check if we are running this notebook in the CNTK internal test machines by looking for environment variables defined the... |
8,648 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
DF = pd.read_csv('fake-data.csv')
DF.head()
X = np.array(DF[['x','y']])
Y = np.array(DF['class'])
X_pass = X[Y == 1.0]
X_fail = X[Y == 0.0]
import matplotlib.pyplot as plt
import seaborn as sns
plt.figure(figsize=(15, 10))
sns.set(sty... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The data we want to investigate is stored in the file 'fake-data.csv'. It is data that I have found somewhere. I am not sure whether this dat... |
8,649 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0., 2. * np.pi, 100)
x = np.cos(t) + np.cos(2. * t)
y = np.sin(t)
N = 100
rand = np.array([np.random.uniform(low=-3, high=3, size=N), np.random.uniform(low=-3, high=3, size=N)]).T
fig, ax = plt.subplots(1, 1, figsize=(7, 7... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Le même principe peut être appliqué pour calculer un volume.
Step2: The function to integrate
Step3: Random points
Step4: Numerical computati... |
8,650 | <ASSISTANT_TASK:>
Python Code:
import math
x = 2
e_to_2 = x**0/math.factorial(0) + x**1/math.factorial(1) + x**2/math.factorial(2) + x**3/math.factorial(3) + x**4/math.factorial(4)
print(e_to_2)
print(math.exp(2))
import math
x = 2
e_to_2 = 0
for i in range(5):
e_to_2 += x**i/math.factorial(i)
print(e_to_2)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Our Taylor Series approximation of $e^2$ was calculated as 7.0. Let's compare our Taylor Series approximation to Python's math.exp() function. P... |
8,651 | <ASSISTANT_TASK:>
Python Code:
#the observations
times = np.array([2.0,4.0, 6.0, 8.0])[:,None]
distances = np.array([2.0,8.0,18.0,32.0])[:,None]
#model configuration
kernel = GPy.kern.Integral(input_dim=1,variances=10.0)
m = GPy.models.GPRegression(times,distances,kernel)
m.optimize()
#m.plot_f()
#prediction for af... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ages of people living in Kelham island
Step2: Predicted range of weights of a child
Step3: We now have a set of
|
8,652 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append("../../..")
from batchflow import B, V, W
from batchflow.opensets import MNIST
from batchflow.models.torch import ResNet18
dataset = MNIST()
model_config = {
'inputs/labels/classes': 10,
'loss': 'ce',
'profile': True,
}
pipeline = (dataset.train.p
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To collect information about model training times (both on CPU and GPU), one must set profile option in the model configuration to True
Step2: ... |
8,653 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
pd.Series?
animals = ['Tiger', 'Bear', 'Moose']
pd.Series(animals)
numbers = [1, 2, 3]
pd.Series(numbers)
animals = ['Tiger', 'Bear', None]
df = pd.Series(animals)
df['number_column'] = -99999
df
numbers = [1, 2, None]
pd.Series(numbers)
import numpy as np
np.nan == No... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Querying a Series
Step2: The DataFrame Data Structure
Step3: Dataframe Indexing and Loading
Step4: Querying a DataFrame
Step5: Indexing Data... |
8,654 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
from itk import tubes_from_file
tubes = tubes_from_file("data/Normal071-VascularNetwork.tre")
print(type(tubes))
print(tubes.dtype)
print(len(tubes))
print(tubes.shape)
print('Entire points 0, 2:')
print(tubes[:4:2])
print('\nPosition of points 0, 2')
print(tubes['... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The result is a NumPy Record Array where the fields of the array correspond to the properties of a VesselTubeSpatialObjectPoint.
Step2: The len... |
8,655 | <ASSISTANT_TASK:>
Python Code:
with open("./cat_food.txt", 'r') as fi:
food = fi.read().splitlines()
# Example:
# target_cat = ['Restaurants', 'Food'] # to be continued...
target_cat = food
df = pd.read_pickle("./UC01_df_uc_open.p")
print df.shape
df = df[df.categories.apply(lambda x: not set(x).isdisjoint(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: For now, start from here...
Step2: Part 3 - Missing Values
Step3: Part 4 - Join & output
|
8,656 | <ASSISTANT_TASK:>
Python Code:
img_count = 0
def showimg(img):
muki_pr = np.zeros((500,500,3))
l =img.tolist()
count = 0
for x in range(500):
for y in range(500):
if l[count][0] >= .5:
muki_pr[y][x] = 1
else:
muki_pr[y][x] = 0
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Muki NN
|
8,657 | <ASSISTANT_TASK:>
Python Code:
import matplotlib as mpl
import matplotlib.pyplot as plt
import random
import numpy as np
import beadpy
import pandas as pd
import math
%matplotlib inline
def trajectory_simulator(pre_duration = 250, #Mean event start time
pre_sigma = 50, #Sigma of event start ti... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: A function to simulate trajectories.
Step2: Simulation of a large number of events
Step3: In this case, the info we are interested in is the r... |
8,658 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import problem_unittests as tests
import tarfile
cifar10_dataset_folder_path = 'cifar-10-batches-py'
# Use Floyd's cifar-10 dataset if ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
8,659 | <ASSISTANT_TASK:>
Python Code:
5 + 5
x = 5
y = 'Hello There'
z = 10.5
x + 5
x = 1
print ('The value of x is ', x)
x = 2.5
print ('Now the value of x is ', x)
x = 'hello there'
print ('Now it is ', x)
print (round(3.14))
help(round)
import builtins
dir(builtins)
print (y)
y + 5
type(1)
type('hello')
type(2.5)
type(T... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Assignments versus equations
Step2: Calling Functions
Step3: Later we will discuss how to built our own function
Step4: The type function
Ste... |
8,660 | <ASSISTANT_TASK:>
Python Code:
list1=[1,2,3,4]
print(list1)
list2=["a","b","c","d"]
print(list2)
list3=[True, False, True]
print(list3)
list3=[1,2,"c","d"]
print(list3)
list4=[2>3, 2, 4, 3>2]
print(list4)
la=[1,2,3]
lb=["1","2","3"]
print(la+lb)
la.append(4)
print(la)
lb+=la
print(lb)
la=[1,2,3,4,5,6,7,8,9,10]
print(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's notice a few key things
Step2: Slicing
Step3: Exercises
Step4: Exercises
Step5: Dictionaries
Step6: Unlike with lists, we cannot acce... |
8,661 | <ASSISTANT_TASK:>
Python Code:
# This line configures matplotlib to show figures embedded in the notebook,
# instead of opening a new window for each figure. More about that later.
# If you are using an old version of IPython, try using '%pylab inline' instead.
%matplotlib inline
%load_ext snakeviz
import numpy as np... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Using Mathematica, I can find the 4*2 equations
Step2: I am going to substitute all density matrix elements using their corrosponding network e... |
8,662 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from sklearn import cross_validation
from sklearn import metrics
from sklearn import linear_model
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid", font_scale=1)
%matplotlib inline
# Load train data
# Given size of tra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Part 1. Identify the Problem
Step2: Part 3. Parse, Mine, and Refine the data
Step3: Check for missing values and drop or impute
Step4: Wrangl... |
8,663 | <ASSISTANT_TASK:>
Python Code:
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.optimizers import SGD
class SimpleNN(ContinuousTransform):
def init_func(self,target_df,X_train_df,y_train_df,X_test_df,y_test_df):
model=Sequential()
model.add(Dens... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The class allows use to replace all layers after a given index in the model. In this example, we replace the last layer (a single softmax activa... |
8,664 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
# use seaborn plotting defaults
import seaborn as sns; sns.set()
from sklearn.cluster import KMeans
from sklearn.datasets.samples_generator import make_blobs, make_circles
from sklearn.utils impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Introduction
Step2: Note that we have computed two data matrices
Step3: Note, again, that we have computed both the sorted (${\bf X}_{2s}$)... |
8,665 | <ASSISTANT_TASK:>
Python Code:
import niche_vlaanderen as nv
import matplotlib.pyplot as plt
simple = nv.Niche()
simple.run_config_file("simple.yml")
full = nv.Niche()
full.run_config_file("full.yml")
delta = nv.NicheDelta(simple, full)
ax = delta.plot(7)
plt.show()
delta.table.head()
delta.write("comparison_output",... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: It is also possible to show the areas in a dataframe by using the table attribute.
Step2: Like Niche, NicheDelta also has a write method, which... |
8,666 | <ASSISTANT_TASK:>
Python Code:
# some standard modules
import csv, os, sys
from collections import Counter
import numpy as np
from scipy.stats import pearsonr
# now a module that I wrote myself, located
# a few directories up, in the software
# library for this repository
sys.path.append('../../lib')
import FileCabinet... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Loading the General Inquirer.
Step2: The next stage is to translate the Inquirer. It begins as a table where word senses are row labels, and th... |
8,667 | <ASSISTANT_TASK:>
Python Code:
# Connect to db
eng = nivapy.da.connect()
# Query projects
prj_grid = nivapy.da.select_resa_projects(eng)
prj_grid
prj_df = prj_grid.get_selected_df()
print(len(prj_df))
prj_df
# Get stations
stn_df = nivapy.da.select_resa_project_stations(prj_df, eng)
print(len(stn_df))
stn_df.head()
#... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Query ICPW projects
Step2: 2. Get station list
Step3: 3. Get parameters
Step4: 4. Get chemistry data
Step5: So, there are 262 stations wi... |
8,668 | <ASSISTANT_TASK:>
Python Code:
# Installing the necessary libraries.
!pip install -q tensorflow-recommenders
!pip install -q --upgrade tensorflow-datasets
# Importing the necessary modules.
import pprint
%matplotlib inline
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
import nu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Toy Example
Step2: Let's generate the data that follows the distribution, and split the data into 90% for training and 10% for testing.
Step3: ... |
8,669 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
%matplotlib inline
import numpy as np
import nsfg
import first
t = [1, 2, 2, 3, 5]
hist = {}
for x in t:
hist[x] = hist.get(x, 0) + 1
hist
from collections import Counter
counter = Counter(t)
counter
import thinkstats2
hist = th... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Given a list of values, there are several ways to count the frequency of each value.
Step2: You can use a Python dictionary
Step3: You can use... |
8,670 | <ASSISTANT_TASK:>
Python Code:
# setting a variable
a = 1.23
# although just writing the variable will show it's value, but this is not the recommended
# way, because per cell only the last one will be printed and stored in the out[]
# list that the notebook maintains
a
a+1
print(a)
print(type(a))
a="1.23"
print(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The right way to print is using the official print() function in python
Step2: Now you can see that each call to print() will cause output on a... |
8,671 | <ASSISTANT_TASK:>
Python Code:
bltest = MyBaseline(npz_path=npz_test)
bltest.getMSE()
bltest.renderMSEs()
plt.show()
bltest.getHuberLoss()
bltest.renderHuberLosses()
plt.show()
bltest.get_dtw()
bltest.renderRandomTargetVsPrediction()
plt.show()
cur_baseline = MyBaseline(npz_path=npz_train_reduced)
cur_baseline.getMSE(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Baseline is static, a straight line for each input - Train (reduced)
Step2: Baseline is static, a straight line for each input - Train Full
|
8,672 | <ASSISTANT_TASK:>
Python Code:
%reload_ext watermark
%watermark -u -n -t
import sys
sys.path.append('../')
from geqfarm import *
import numpy as np
from matplotlib import pyplot as plt
import seaborn as sns
plt.rcParams["figure.figsize"] = (10, 8)
np.set_printoptions(precision=4)
%matplotlib inline
%load_ext autorelo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This notebooks extends the general equilibrium farm distribution models found in the geqfarm module o also include the possibility that the 'sma... |
8,673 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'messy-consortium', 'sandbox-3', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,674 | <ASSISTANT_TASK:>
Python Code:
a = set()
a.add(3) # Добавление элемента, O(1)
b = {5}
print(a, b)
c = {4, 4, 2, 6} # Элементы не повторяются
print(c) # Порядок элементов не важен
lst = [8, 1, 3, 3, 8]
a = set(lst) # Приведение списка к множеству (выкинули повторения)
print(a)
print(list(a)) # Приведение множества... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Приведение к списку
Step2: Генератор множества
Step3: Стандартные операции
Step4: Удаление элемента
Step5: Размер множества
Step6: Проход п... |
8,675 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo('F4rFuIb1Ie4')
## PDF output using pandoc
import os
### Export this notebook as markdown
commandLineSyntax = 'ipython nbconvert --to markdown 20150916_OGC_Reuse_under_licence.ipynb'
print (commandLineSyntax)
os.system(commandLineSyntax... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The environment
Step2: Running dynamic presentations
Step5: To close this instances press control 'c' in the ipython notebook terminal console... |
8,676 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib
%matplotlib inline
%%time
cast = pd.DataFrame.from_csv('data/cast.csv', index_col=None, encoding='utf-8')
%%time
release_dates = pd.read_csv('data/release_dates.csv', index_col=None,
parse_dates=['date'], infer_datetime_f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Carregando um arquivo csv em um DataFrame do Pandas
Step2: release_dates.csv
Step3: titles
Step4: df.head(n)
Step5: df.tail(n)
Step6: Quant... |
8,677 | <ASSISTANT_TASK:>
Python Code:
from BeautifulSoup import *
import requests
url = "https://careercenter.am/ccidxann.php"
response = requests.get(url)
page = response.text
soup = BeautifulSoup(page)
tables = soup.findAll("table")
my_table = tables[0]
rows = my_table.findAll('tr')
data_list = []
for i in rows:
columns... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Կոդերի սկզբունքը նույնն է նաև մնացած մասնագիտությունների համար
Step2: Պահանջվող որակավորումներ
Step3: Սկզբունքը նույնն է նաև մնացած բոլոր հմտո... |
8,678 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
import numpy as np
import pandas as pd
import statsmodels.api as sm
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
#Reading ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Часто, когда вы имеете дело с величинами, представляющими собой сумму значений показателя за каждый день или за каждый рабочий день, имеет смысл... |
8,679 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import bet.calculateP.simpleFunP as simpleFunP
import bet.calculateP.calculateP as calculateP
import bet.sample as samp
import bet.sampling.basicSampling as bsam
from myModel import my_model
from IPython.display import Image
sampler = bsam.sampler(my_model)
# Initializ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Characterize Parameter Space
Step2: Suggested Changes
Step3: Characterize Data Space
Step4: Solve Problem
Step5: Store Data for Retrieval in... |
8,680 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.1,<2.2"
%matplotlib inline
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
b.add_dataset('lc', times=np.linspace(0,20,501))
b.run_compute(detach=True, model='my... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new Bundle. See Building a System for more details.
Step2: Now we'll add datasets
St... |
8,681 | <ASSISTANT_TASK:>
Python Code:
from matplotlib import pyplot
import numpy
from numpy import linalg
%matplotlib inline
from matplotlib import rcParams
rcParams['font.family'] = 'serif'
rcParams['font.size'] = 16
def Kepler_eqn(e, M):
Takes the eccentricity and mean anomaly of an orbit to solve Kepler's equation
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Content under Creative Commons Attribution license CC-BY 4.0, code under MIT license (c)2014 M.Z. Jorisch
Step3: The Kepler_eqn function uses t... |
8,682 | <ASSISTANT_TASK:>
Python Code:
titles.title.value_counts().head(10)
titles[(titles["year"]>=1930) & (titles["year"]<1940)].title.value_counts().head(3)
t = titles
(t.year // 10 * 10).value_counts().sort_index().plot(kind='bar')
t = titles[titles.title == 'Hamlet']
(t.year // 10 * 10).value_counts().sort_index().plot... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Which three years of the 1930s saw the most films released?
Step2: Plot the number of films that have been released each decade over the histor... |
8,683 | <ASSISTANT_TASK:>
Python Code:
import logging
reload(logging)
logging.basicConfig(
format='%(asctime)-9s %(levelname)-8s: %(message)s',
datefmt='%I:%M:%S')
# Enable logging at INFO level
logging.getLogger().setLevel(logging.INFO)
# Execute this cell to enable verbose SSH commands
logging.getLogger('ssh').setLev... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <br><br><br><br>
Step2: Commands execution on remote target
Step3: Example of frameworks configuration on remote target
Step4: Create a big/L... |
8,684 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
np.random.seed(1)
df = pd.DataFrame({
'A' : ['one', 'one', 'two', 'three'] * 6,
'B' : ['A', 'B', 'C'] * 8,
'C' : ['foo', 'foo', 'foo', 'bar', 'bar', 'bar'] * 4,
'D' : np.random.randn(24),
'E' : np.ran... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
8,685 | <ASSISTANT_TASK:>
Python Code:
# set the midpoint
midpoint = 5
# make two empty lists
lower = []; upper = []
# split the numbers into lower and upper
for i in range(10):
if (i < midpoint):
lower.append(i)
else:
upper.append(i)
print("lower:", lower)
print("upper:", upper)
x = 1 + 2 + 3... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: El script es algo tonto, pero ilustra varios aspectos de la sintaxis de Python.
Step2: It is also possible to continue expressions on the next... |
8,686 | <ASSISTANT_TASK:>
Python Code:
flood_comm_top = flood_comm_sum.sort_values(by='Count Calls', ascending=False)[:20]
flood_comm_top.plot(kind='bar',x='Community Area',y='Count Calls')
# WBEZ zip data
wbez_zip = pd.read_csv('wbez_flood_311_zip.csv')
wbez_zip_top = wbez_zip.sort_values(by='number_of_311_calls',ascending=Fa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Zip Code Data Comparison - WBEZ, Current Data
Step2: Community Area Breakdown for 2009-2015
|
8,687 | <ASSISTANT_TASK:>
Python Code:
import pyisc;
import visisc;
import numpy as np
import datetime
from scipy.stats import poisson, norm, multivariate_normal
%matplotlib wx
%gui wx
n_sources = 10
n_source_classes = 10
n_events = 100
num_of_normal_days = 200
num_of_anomalous_days = 10
data = None
days_list = [num_of_normal_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Likewise, as before we need to create an event parth function and a severity level function.
Step2: Next, we need to make an subclass or an ins... |
8,688 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.image as mpimg
f = mpimg.imread('../data/cameraman.tif')
print(f.min(), f.max())
%matplotlib inline
import matplotlib.pyplot as plt
plt.imshow(f, cmap = 'gray')
plt.colorbar()
nbins = 20
h, bin_edges = np.histogram(f, nbins,(0,255))
print('h=\n',h)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: O que temos no retorno da função np.histogram é a contagem do número de pixels com valores em uma determinada faixa. No exemplo acima, a imagem ... |
8,689 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
%matplotlib inline
import time
import numpy as np
from landlab.io import read_esri_ascii
from landlab import RasterModelGrid as rmg
from landlab import load_params
from Ecohyd_functions_DEM import (
Initialize_,
Empty_arrays,
Create_PET_lo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Note
Step2: Include the input file that contains all input parameters needed for all components. This file can either be a Python dictionary or... |
8,690 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
test_data = pd.read_csv("../data/event-text-highlight.csv")
test_data["tagged_events"][0:30]
import crowdtruth
from crowdtruth.configuration import DefaultConfig
class Config(DefaultConfig):
inputColumns = ["doc_id", "sentence_id", "events", "events_count", "origi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Notice the diverse behavior of the crowd workers. While most annotated each word individually, the worker on row 2 annotated a chunk of the sent... |
8,691 | <ASSISTANT_TASK:>
Python Code:
import tigl3.curve_factories
import tigl3.surface_factories
from OCC.gp import gp_Pnt
from OCC.Display.SimpleGui import init_display
import numpy as np
# list of points on NACA2412 profile
px = [1.000084, 0.975825, 0.905287, 0.795069, 0.655665, 0.500588, 0.34468, 0.203313, 0.091996, 0.02... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create profile points
Step2: Create guide curve points
Step3: Build profiles curves
Step4: Check
Step5: Result
Step6: Visualize the result
|
8,692 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
learning_rate = 0.01
training_epochs = 1000
num_labels = 3
batch_size = 100
x1_label0 = np.random.normal(1, 1, (100, 1))
x2_label0 = np.random.normal(1, 1, (100, 1))
x1_label1 = np.random.normal... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generated some initial 2D data
Step2: Define the labels and shuffle the data
Step3: We'll get back to this later, but the following are test i... |
8,693 | <ASSISTANT_TASK:>
Python Code:
# To start, import numpy and matplotlib.
import matplotlib.pyplot as plt
import numpy as np
# Then we import the package
import pymt.models
hydrotrend = pymt.models.Hydrotrend()
import pymt
pymt.__version__
# Get basic information about the HydroTrend model
help(hydrotrend)
# Set up H... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Learn about the Model Input
Step2: Exercise 1
Step3: With the cat command you can print character by character one of the two input files that... |
8,694 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import active_subspaces as ac
import numpy as np
import matplotlib.pyplot as plt
from wing_functions import *
M = 1000 #This is the number of data points to use
#Sample the input space according to the distributions in the table above
Sw = np.random.uniform(150, 200, (... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We first draw a set of inputs from the parameter space according to the distributions in the table above and compute the function's value at eac... |
8,695 | <ASSISTANT_TASK:>
Python Code:
# Import Numpy, TensorFlow, TFLearn, and MNIST data
import numpy as np
import tensorflow as tf
import tflearn
import tflearn.datasets.mnist as mnist
# Retrieve the training and test data
trainX, trainY, testX, testY = mnist.load_data(one_hot=True)
# Visualizing the data
import matplotli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Retrieving training and test data
Step2: Visualize the training data
Step3: Building the network
Step4: Training the network
Step5: Testing
... |
8,696 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-mm', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,697 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', validation_size=0)
img = mnist.train.images[2]
plt.imshow(img.reshape((28, 28)), cmap='... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Below I'm plotting an example image from the MNIST dataset. These are 28x28 grayscale images of handwritten digits.
Step2: We'll train an autoe... |
8,698 | <ASSISTANT_TASK:>
Python Code:
from pymongo import MongoClient
client = MongoClient() #connects to the running mongod instance
users = client.test_database.user #creates database "test_database" and collection "user" if they do not already exist
users.remove({}) #Making sure that the collection is empty before I start
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In SQL databases hold tables, tables contain rows and each row is made up of a number of columns. In NoSQL databases hold collections, collectio... |
8,699 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from ipywidgets import interact
x = np.linspace(0, 1, 101)
k = 2
f = np.sin(2*np.pi * k * x)
plt.plot(x, f)
def sine_plotter(wave_number):
plt.plot(x, np.sin(2*np.pi * x * wave_number), 'r')
sine_plotter(5)
int... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Define a sine wave
Step2: Plot the sine wave
Step3: Define a function that allows a user to vary the wavenumber of the sine wave
Step4: For e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.