benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf b7c1660c-b09e-5467-b71a-33da2e3d89b1
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import pandas as pd
import requests
from io import StringIO
def task_func(csv_url, sort_by_column="title"):
"""
Fetches data from a given CSV URL and returns a pandas DataFrame sorted based on the specified column.
Parameters:
- csv_url (str): The URL to fetch the CSV data from.
- sort_by_column (str): The column name based on which the data needs to be sorted. Default is "title".
Returns:
DataFrame: The pandas DataFrame that sorted based on the specified column.
Requirements:
- pandas
- requests
- io.StringIO
Raises:
Exception: If the response status code is not 200.
Example:
>>> task_func("http://example.com/data.csv", sort_by_column="title")
id title price
0 1 Apple 0.3
1 2 Banana 0.5
2 3 Cherry 0.2
>>> task_func("http://example.com/data.csv", sort_by_column="price")
id title price
2 3 Cherry 0.2
0 1 Apple 0.3
1 2 Banana 0.5
"""
instruct prompt
Fetches data from a given CSV URL and returns a pandas DataFrame sorted based on the specified column. >>> task_func("http://example.com/data.csv", sort_by_column="price") id title price 2 3 Cherry 0.2 0 1 Apple 0.3 1 2 Banana 0.5
The function should raise the exception for: Exception: If the response status code is not 200.
The function should output with:
DataFrame: The pandas DataFrame that sorted based on the specified column.
You should write self-contained code starting with:
Code
import pandas as pd
import requests
from io import StringIO
def task_func(csv_url, sort_by_column="title"):
code prompt
Code
import pandas as pd
import requests
from io import StringIO
def task_func(csv_url, sort_by_column="title"):
entry point
task_func
libs
- pandas
- io
- requests
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
initial import