{ "data": { "question": { "questionId": "3070", "questionFrontendId": "2887", "boundTopicId": null, "title": "Fill Missing Data", "titleSlug": "fill-missing-data", "content": "
\nDataFrame products
\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| name | object |\n| quantity | int |\n| price | int |\n+-------------+--------+\n
\n\nWrite a solution to fill in the missing value as 0
in the quantity
column.
The result format is in the following example.
\n\n\n
\nExample 1:\nInput:+-----------------+----------+-------+\n| name | quantity | price |\n+-----------------+----------+-------+\n| Wristwatch | None | 135 |\n| WirelessEarbuds | None | 821 |\n| GolfClubs | 779 | 9319 |\n| Printer | 849 | 3051 |\n+-----------------+----------+-------+\nOutput:\n+-----------------+----------+-------+\n| name | quantity | price |\n+-----------------+----------+-------+\n| Wristwatch | 0 | 135 |\n| WirelessEarbuds | 0 | 821 |\n| GolfClubs | 779 | 9319 |\n| Printer | 849 | 3051 |\n+-----------------+----------+-------+\nExplanation: \nThe quantity for Wristwatch and WirelessEarbuds are filled by 0.\n", "translatedTitle": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Easy", "likes": 26, "dislikes": 3, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "{\"headers\":{\"products\":[\"name\",\"quantity\",\"price\"]},\"rows\":{\"products\":[[\"Wristwatch\",null,135],[\"WirelessEarbuds\",null,821],[\"GolfClubs\",779,9319],[\"Printer\",849,3051]]}}", "categoryTitle": "pandas", "contributors": [], "topicTags": [], "companyTagStats": null, "codeSnippets": [ { "lang": "Pandas", "langSlug": "pythondata", "code": "import pandas as pd\n\ndef fillMissingValues(products: pd.DataFrame) -> pd.DataFrame:\n ", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"8.9K\", \"totalSubmission\": \"12.6K\", \"totalAcceptedRaw\": 8929, \"totalSubmissionRaw\": 12560, \"acRate\": \"71.1%\"}", "hints": [ "Consider using a build-in function in pandas library to fill the missing values of specified columns." ], "solution": { "id": "2112", "canSeeDetail": true, "paidOnly": false, "hasVideoSolution": false, "paidOnlyVideo": true, "__typename": "ArticleNode" }, "status": null, "sampleTestCase": "{\"headers\":{\"products\":[\"name\",\"quantity\",\"price\"]},\"rows\":{\"products\":[[\"Wristwatch\",null,135],[\"WirelessEarbuds\",null,821],[\"GolfClubs\",779,9319],[\"Printer\",849,3051]]}}", "metaData": "{\n \"pythondata\": [\n \"products = pd.DataFrame([], columns=['name', 'quantity', 'price']).astype({'name':'object', 'quantity':'Int64', 'price':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"fillMissingValues\",\n \"languages\": [\n \"pythondata\"\n ]\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [], "enableRunCode": true, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"pythondata\": [\"Pandas\", \"
Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0
\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }