benchmarks.wiki / Public workspace
..·::-==++*********++==-::·.. ..·:--==+++++==--::··........·::-=+**#%@@@@%#*+=-:·
..···::-----===------:::··... ..···::::::::::···........··::--==++@@@@@@%#*+=-:·.
......············....... ..........................·····:**@@@@@@%#*+=-:·.
·:++@@@@@@%#*+=-:·.
··==######*++=-:·..
..--+++====--::··.
..··:::::::····...
...............
......·····::::::::····..... ...............
...............····:::--==+++++++++==--:::···..........·····:::::::·····..................
......················:::--=++*##%%%@%%%##**+==---::::::::----=======----:::··········:::·····...
..·:--=+**##%%%%%#**+=-:·. ..·::---===--::··.. ..··:--=++**######*+=-:··.
...···:::---======--::··.. ...········.... ...··::---====%%%%%%#*+=-:·.
.........·······..... .....······++%%@@@@%#*+=-:·.
··==%%%%%%%#*+=-:·.
··--****##**++=-:·.
..::-====++===--:·.
..···::-----::··.
...········..
....··..
.........··················....... ................................ .....
....··:::::::-----===========---::::····........······:::::-----:::::··················...
..···::------====+++****######***++==---:::::::::::---====+++++++====----------=====----::·..
.·:-=+*##%@@@@@%%#*+=-:·. ..··::------::··.. ..···::::----------::··..
..··::--===++++==--:··.. ........... ...·····::::::=======--:··.
.....·········.... ............:-+++++++==-:··.
..--++*****+==-:·.
..::+++**#**+=--:.
..·:===+****++=-:·.
.·:--=++*+++=-:·.
..·::-==++==-:·.
..·:---==--:·.
...···::::::·······..... .........·············..................... ..·::---::·.
..··:-==++++++++++===--::···..... ........····::::---------------::::-----------:::··... .··::::··.
..·::-=+###%%%%@@%%%%##*++=--:···........····:::--===++++++++++++++++++++*****##***++=--:·.. ..·····..
..·::-=+*##%%%%%%##**+==-::··..........··::---=====--::·.. .....·····...
...··::--========---::··.... .....········.... ....······...
....··········..... ..··········...
.·:::::::::··..
..··-----=--::··..
..··-===++==--:··.
..·:==+++*++=--:·.
.··-=++*#**+=-:·.
.·--=+*##**+=-:·.
...···::····.... .........··································..... ..:-=++*#**+=-:·.
..·:-==+***++==--:··... ....····::::-------------------====++++++===--::··... .·:-=+****+=-:·.
.·:-+*#%@@@@@@%##*+=-:··.. ....···::---================+++**##%%%%%%%%#**+=-::·.. ..·:-=+++++=-:·.
..··::--==+++*********+++++=====----------===++********++=--:··. .··::---::·.
...···::::-----------::::::·············:::::------:::···.. .··:::::··.
.........···............. ................. ..···::···.
..·······..
....·······..
...···········..
··::::::::····..
..··-------:::··..
..::==++++=--::·..
.......... ......................·······:::::::::::·····.................:-+*****++=-:··.
.··::-----::··... ......·····:::::::::::::::::---===++++++++++==--:::···.......···:::--**#####*+=-:·.
.·:-=+**##**+=-::·... ....····::::::::::::::::::--==++*##%%%%%%%##*++=--::···.....··::--=++*##%%%%#*=-:·.
..·::-=+++++++==========+++++++++++++++***##%%%@@@@@@@@%##*+==-::····........ .·:-=++***+=-:·.
...·::-------::::::::::::::::::::::::-----=====+++====--:::··................ ··:=++*++=-:·.
....·····..............................··········...... ...... ..·:-+++==-:·.
.··:=====-:·.
.·:------:·.
..·::---::·.
..··:::::··.
....···::···..
..············..
......... ........·····::::::::::·······..................··-:::::::···..
....................................·····............···::---==++++++++===---::::::::::::-----------====---::··..
..····:::·····...............················..........··::-=++**#######**++==--::::::---==++***######***+++=-:··..
.·::--=====----======+++++++++++****##%%@@@@@@@@@@@@@@%##*+++====-------:::··.. .··:-==++**##*+==-:·.
..··:::--:::::······::::::::::::----====++++++++++===--::::···············.... ..··:++**##**+=-:·.
.....··............................············......... .............. ··=+**###*+=-:·.
.·-=+**#**+=-:·.
..:-=+****+=-:·.
.::-=+**++=-:·.
.·::-=+++=--:·.
.·::-===--::·.
.··::----::·..
................. ....·····:::::::··········............. ..····:::::··..
...····:::::::················....... ...··::--===========-----:::::::--------::::·····..····:::···...
...·::::--------------:::::::::···.... ..·::-==++*******+++==--------===+++*******+++==---::::::···...
.··::--=======================+++**##%@@@@@@@@@@@%%###**************+++==--::···.........····:::---===+++**#*++=-:·.
...···::::::::::::::::::::::::----====++++++===----::::::::::::::::::::···.... ....···:::::+++****+==-:·.
...............................·········....... .............. .....:-++*****+=-::·.
..:-+*****++=-:··.
..:-+*****++=-:·..
..:-+*****++=-:·..
..::++****+=--:·.
..::=+++**+=-:··.
.·:==++++=--:·..
....······................. ....················.......... .··--====--:··.
..··:-----------:::::::::::····.... ..··::---=========----::::::::··········..........····------::·...
..·:-==++++++++++++++++++===--::··... ..··:-==++**###***+++==------------=====------::::::::::::::::··..
.··:-==+*+++===---:::::::::--==++***########************####%%%%####***+++===------:::::::···::::--==+**#%%@%#*+=-:·
..··::-----:::::········:::::------------:::::······:::::--------:::::···························::::+**####*+=-:·.
....................................... .............. ................::+++****+=-:··.
..::++++++==-:··.
..--+++++==-:··..
··--++++==-::·..
··--*+++==-:·..
··=-**++==-:·..
··=-**++=-:··.
.....······................ ....·············..... ......····--*++==-:·..
..··::------=========-----:::··.... ....··::--==++++++===---::···.... ...··:::-------++==-:··.
.·::-=+***#####%%%%%%###**+==-::··......··::-=++*##%%%%%%%##**+==--::····............···::--===++++++===-::·.
.·:---===--::·····..·····::---==================++**##%%%%@@@@@%%%%####***+++==---::·······:::-==+**#%%%@@@@%#+=-:·.
..··:::--::::··········:::::::--::::::············:::-------------------::::::::::·············:::--==##%%%%#*+=::·.
.....···........................... .................................................--******+=-::·.
..--+++++==-:·..
..::====--:··.
..::=---::·..
··-:=--:··.
··--=--:·..
··--==-:·..
....················..... ....·············.... ...····::::::···=-+=-:··.
...··:--=====++++++===--:::··........···::-==+++*****++==--::·.. ..··:--==++++++++==-+=-:··.
.··:-=+*##%%%@@@@@@%%#**+=--::·····:::-=+*##%@@@@@@@@@@%%#*+=-:··. .··:-=+*#%%@@@@%%#**+=-:·..
..···::::···.....····::::---------::::----==++**##%%@@@@@@@@@%%%###**++===--:::······:::--=++***#########***+=-:··.
...····:::·······:::::::---::::::··········::::---=============--------:::::············::::---=======##***+=-:··..
.....·....···············...... ..................................................·······==***++=-:··..
··--++==-:··..
·.-:=--:··.
..::-:··.
..:·:··.
·.:·:·..
·.:·:·..
....·············.... .....·····::······... ...···::::::::::::····::-:·.
..··:-===+++++===--::···........··::--=+++*******++=--:·.. .·:--=+***********++=--:-:··.
..·:-=*##%%%%%%%##*+==-::·······:--=+*#%@@@@@@@@@@@@%#*+=-·. .·:=+*#%@@@@@@@@@@@%#*+=-::·...
.....·······::::------------::::----==+**#%%@@@@@@@@@@@%%#**++=--:::········:::--==+++***********++==---::··.....
...···::::::-------------:::::::::::---===++++***+++++===---:::·····.......····:::---============---==-:::··....
....········::::·······.............···················........... ........················--=--::··...
··-:--:··..
·.::::·..
..····.
..·.·.
..·...
..·...
...·········.... .....···········.... ...····:::::::::::::····..···...
..·::-=====--::··... ...··:--==+++***+++==-:··. .··:-==+*************++=--:··:···.........
.··:-+*##***++=-::·... ...··:-=+**#%@@@@@@@@@@%#+=-:·. .·:-=+#%@@@@@@@@@@@@@@%#*+=--:::········...
...··:----==========---------==+**#%@@@@@@@@@@@@@%#*+=-::·... ...··:--==++****####****++==--:··... ....
...··:----========-----::::----==+++*************++=--:··... ...··:::--===++++++++===---::··.··............
...···:::::::::·······....······::::::::::::::::····... ....·····::::::::::·····..··:···.........
..:·:···........
..····......
..·.·...
......
. .... .......
. .........···...
.....·..... .....·······...... .....····:::::::::::····.... ..·····::::···..
..··::::::··.. ...··::---=====---::··... ..···:--==+++********+++==-:::····::::-----::··.
..·::-====-:··. ..··:-==+**#######**+=-::·. .··:-=++*#%@@@@@@@@@@@%%#*++==--------===---:··.
..··:--========-----::----=++*#%@@@@@@@@@@@@@%#*+-:··. ..··:--==+++**********++==-::··.. ..······.
..··:---===-----:::::::---==++***************+=--:·.. ..··::--===+++++++++===--::···......···::::::··.
...··············.....·····:::::::::::::::::::··... ...····:::::::::::::····.....··:::::----::··.
..··-:------:::·..
..··::::---:::··..
..··:::::::::··..
..·.··::::::···..
..··:::::::··..
..::::----::··..
..... .......................... .....······:·······....... ··::--===--::·..
...···... ...····::::::::::::::········............···::---===++++===---:::·········--===+==--:··.
.···:::··.. ...··::---======-----::::::··············:::--==++**###%%%###**+==---:::::----===++==--:··.
..··::---:::·········::-=++*#%@@@@@@@@@@%#*+=-:·.. ...··::--==+++*******++==-::·... ..··:-=====--:·.
..···::::···········::--==+*************+==-:·.. ...··::---===+++++===---::····....··--=+*****+=-:·.
....................···:::::::::::::::::··... ....····::::::::::·····........::++**#%##*+=-:·
..--***##%#*+=-:·.
..--+******+=-:··.
..::=+++++==-::·..
..::-=====--::·..
..··-------::··..
··:------::··..
.....······:::::·····.... ......·······....... ··-------::··..
..... ....····:::---=========--::···...........···:::------::::····........·····-------::··..
..···... .....·····:::---==+++*****+++==--::::··::::---===++++++===--:::········:::::-------::···..
..... ..·::-=+**##%%%%%##**+==-:··.. ..··:--=++******++=--::··.......·::-=+*#%@%#*+=-:·.
.. ..··::--==++******++==--:··... ...··::---======---:::··········::--#%@@@@%#*+=-:·.
....···:::::::::::::···... .....··············..........···=+@@@@@@%#*+=-:·.
··++@@@@@@%#*+=-·.
··==%%%%%%#*+=-:·.
··--****++==-:··..
..::====---:···..
..··::::::···...
..·······....
.....····::::::::::···.... ............... ..·····......
....··::--==++*****+++=--::··............····::::::·····.....................··.........
......... ......··::-==+*##%%@@@%%%#**+==-:::::·:::::-----==----:::·····....··············...........
██████╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ███████╗██████╗ ███████╗███╗ ██╗ ██████╗██╗ ██╗
██╔══██╗██║██╔════╝ ██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔══██╗██╔════╝████╗ ██║██╔════╝██║ ██║
██████╔╝██║██║ ███╗██║ ██║ ██║██║ ██║█████╗ ██████╔╝█████╗ ██╔██╗ ██║██║ ███████║
██╔══██╗██║██║ ██║██║ ██║ ██║██║ ██║██╔══╝ ██╔══██╗██╔══╝ ██║╚██╗██║██║ ██╔══██║
██████╔╝██║╚██████╔╝╚██████╗╚██████╔╝██████╔╝███████╗██████╔╝███████╗██║ ╚████║╚██████╗██║ ██║
╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝$ open /benchmarks/bigcodebench/tasks/default--v0~2e1~2…▌ posts · files
BigCodeBench / BigCodeBench v0.1.0_hf 02f8abc1-6c8f-574b-8f97-2daeb0a329e2
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import pandas as pd
import pandas as pd
import random
def task_func(csv_file, column_name='data', pattern='\d+[xX]', sample_size=None, seed=42):
"""
Search for matches with a specified regex pattern in a given column of a CSV file and optionally return a random sample of these matches.
The random sampling is implemented by generating a random list of integers which are used as indices.
The number of generated indices is given by sample_size.
Parameters:
csv_file (str): Path to the CSV file.
column_name (str, optional): The name of the column to search. Defaults to 'data'.
pattern (str, optional): The regex pattern to search for. Defaults to '\d+[xX]'.
sample_size (int, optional): Number of random samples to return from the matches. If None, all matches are returned. Defaults to None.
seed (int, optional): Seed for the random number generator for reproducibility. Defaults to 42.
Returns:
DataFrame: A pandas DataFrame containing either all the rows with matches or a random sample of them.
Requirements:
- pandas
- random: for generating the random list of indices
Example:
>>> result = task_func('sample.csv', column_name='data', pattern='\d+[xX]', sample_size=10, seed=42)
>>> print(result)
index data
210 211 Fund several agency oil. Evening plant thank t...
45 46 Language interest four take old. Education if ...
525 526 Action million cultural stand. Heart explain a...
465 466 Security face clearly every could. Image beaut...
430 431 Popular produce floor part soldier human. Youn...
260 261 Customer game focus respond that central. Nigh...
195 196 The writer parent. Life social house west ten ...
165 166 Main hotel production nothing.\r\nCoach voice ...
810 811 Early right nature technology. Conference mind...
60 61 Interest require gas wall. Different it see fi...
"""
instruct prompt
Search for matches with a specified regex pattern in a given column of a CSV file and optionally return a random sample of these matches. The random sampling is implemented by generating a random list of integers which are used as indices. The number of generated indices is given by sample_size.
The function should output with:
DataFrame: A pandas DataFrame containing either all the rows with matches or a random sample of them.
You should write self-contained code starting with:
Code
import pandas as pd
import pandas as pd
import random
def task_func(csv_file, column_name='data', pattern='\d+[xX]', sample_size=None, seed=42):
code prompt
Code
import pandas as pd
import pandas as pd
import random
def task_func(csv_file, column_name='data', pattern='\d+[xX]', sample_size=None, seed=42):
entry point
task_func
libs
- pandas
- random
Discussion
No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
Source and history
- task_id
02f8abc1-6c8f-574b-8f97-2daeb0a329e2- task_key
default--v0~2e1~2e0~5fhf--02f8abc1-6c8f-574b-8f97-2daeb0a329e2- task_revision_id
- 1
- config / split
- default / v0.1.0_hf
initial import