message_type
stringclasses
2 values
message
stringlengths
2
232
message_id
int64
0
1
conversation_id
int64
0
2.38k
instruction
load a file `file.py` into the python console
0
800
output
exec(compile(open('file.py').read(), 'file.py', 'exec'))
1
800
instruction
SQLAlchemy count the number of rows in table `Congress`
0
801
output
rows = session.query(Congress).count()
1
801
instruction
null
0
802
output
subprocess.call(['test.sh', str(domid)])
1
802
instruction
read excel file `file_name` using pandas
0
803
output
dfs = pd.read_excel(file_name, sheetname=None)
1
803
instruction
unpack the binary data represented by the hexadecimal string '4081637ef7d0424a' to a float
0
804
output
struct.unpack('d', binascii.unhexlify('4081637ef7d0424a'))
1
804
instruction
Get index of numpy array `a` with another numpy array `b`
0
805
output
a[tuple(b)]
1
805
instruction
find all possible sequences of elements in a list `[2, 3, 4]`
0
806
output
map(list, permutations([2, 3, 4]))
1
806
instruction
sort a list `unsorted_list` based on another sorted list `presorted_list`
0
807
output
sorted(unsorted_list, key=presorted_list.index)
1
807
instruction
null
0
808
output
datetime.datetime.now() - datetime.timedelta(days=1)
1
808
instruction
create a dataframe `d` filled with zeros with indices from 0 to length of `data` and column names from `feature_list`
0
809
output
d = pd.DataFrame(0, index=np.arange(len(data)), columns=feature_list)
1
809
instruction
find the index of sub string 'World' in `x`
0
810
output
x.find('World')
1
810
instruction
find the index of sub string 'Aloha' in `x`
0
811
output
x.find('Aloha')
1
811
instruction
find the index of sub string 'cc' in string 'sdfasdf'
0
812
output
'sdfasdf'.index('cc')
1
812
instruction
find the index of sub string 'df' in string 'sdfasdf'
0
813
output
'sdfasdf'.index('df')
1
813
instruction
find the index of sub string 'a' in string `str`
0
814
output
str.find('a')
1
814
instruction
find the index of sub string 'g' in string `str`
0
815
output
str.find('g')
1
815
instruction
find the index of sub string 's' in string `str` starting from index 11
0
816
output
str.find('s', 11)
1
816
instruction
find the index of sub string 's' in string `str` starting from index 15
0
817
output
str.find('s', 15)
1
817
instruction
find the index of sub string 's' in string `str` starting from index 16
0
818
output
str.find('s', 16)
1
818
instruction
find the index of sub string 's' in string `str` starting from index 11 and ending at index 14
0
819
output
str.find('s', 11, 14)
1
819
instruction
sort list of date strings 'd'
0
820
output
sorted(d, key=lambda x: datetime.datetime.strptime(x, '%m-%Y'))
1
820
instruction
Get all the sentences from a string `text` using regex
0
821
output
re.split('\\.\\s', text)
1
821
instruction
null
0
822
output
re.split('\\.\\s', re.sub('\\.\\s*$', '', text))
1
822
instruction
get all characters in string 'foobar' up to the fourth index
0
823
output
"""foobar"""[:4]
1
823
instruction
cut a string by delimiter '&'
0
824
output
s.rfind('&')
1
824
instruction
cut a string using delimiter '&'
0
825
output
s[:s.rfind('&')]
1
825
instruction
find a tag `option` whose `value` attribute is `state` in selenium
0
826
output
driver.find_element_by_xpath("//option[@value='" + state + "']").click()
1
826
instruction
append line "appended text" to file "test.txt"
0
827
output
with open('test.txt', 'a') as myfile: myfile.write('appended text')
1
827
instruction
append line "cool beans..." to file "foo"
0
828
output
with open('foo', 'a') as f: f.write('cool beans...')
1
828
instruction
append to file 'test1' content 'koko'
0
829
output
with open('test1', 'ab') as f: pass
1
829
instruction
append to file 'test' content 'koko'
0
830
output
open('test', 'a+b').write('koko')
1
830
instruction
split string 'x+13.5*10x-4e1' into tokens
0
831
output
print([i for i in re.split('([\\d.]+|\\W+)', 'x+13.5*10x-4e1') if i])
1
831
instruction
Find all Chinese characters in string `ipath`
0
832
output
re.findall('[\u4e00-\u9fff]+', ipath)
1
832
instruction
split string `s` by letter 's'
0
833
output
s.split('s')
1
833
instruction
run shell command 'rm -r some.file' in the background
0
834
output
subprocess.Popen(['rm', '-r', 'some.file'])
1
834
instruction
convert a list of dictionaries `listofdict into a dictionary of dictionaries
0
835
output
dict((d['name'], d) for d in listofdict)
1
835
instruction
print current date and time in a regular format
0
836
output
datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
1
836
instruction
print current date and time in a regular format
0
837
output
time.strftime('%Y-%m-%d %H:%M')
1
837
instruction
find consecutive consonants in a word `CONCENTRATION` using regex
0
838
output
re.findall('[bcdfghjklmnpqrstvwxyz]+', 'CONCERTATION', re.IGNORECASE)
1
838
instruction
get a list of indices of non zero elements in a list `a`
0
839
output
[i for i, e in enumerate(a) if e != 0]
1
839
instruction
get multiple integer values from a string 'string1'
0
840
output
map(int, re.findall('\\d+', string1))
1
840
instruction
get the path of Python executable under windows
0
841
output
os.path.dirname(sys.executable)
1
841
instruction
move an x-axis label to the top of a plot `ax` in matplotlib
0
842
output
ax.xaxis.set_label_position('top')
1
842
instruction
move x-axis to the top of a plot `ax`
0
843
output
ax.xaxis.tick_top()
1
843
instruction
Move x-axis of the pyplot object `ax` to the top of a plot in matplotlib
0
844
output
ax.xaxis.set_ticks_position('top')
1
844
instruction
parse string '2015/01/01 12:12am' to DateTime object using format '%Y/%m/%d %I:%M%p'
0
845
output
datetime.strptime('2015/01/01 12:12am', '%Y/%m/%d %I:%M%p')
1
845
instruction
Open image 'picture.jpg'
0
846
output
img = Image.open('picture.jpg') img.show()
1
846
instruction
Open image "picture.jpg"
0
847
output
img = Image.open('picture.jpg') Img.show
1
847
instruction
terminate the script using status value 0
0
848
output
sys.exit(0)
1
848
instruction
abort the execution of the script using message 'aa! errors!'
0
849
output
sys.exit('aa! errors!')
1
849