注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
记录一下编程测试凉经:
1.You are given a file studies.xm/which is an excerpt from scientific database. It contains basic information about a few biomedical studies. Your task is to extract some fields from the XML file and create structured output in the form of a dataframe. Data overview You can access the file using the path ./data/studies.xml All information about a given study is included between ‹item> and ‹/item> tags. The file includes data about seven different studies. Requirements In order to complete the task you must write a function named structure_data that performs the following steps: 1. Extract the following fields for each study (item): o digital object identifier (ol) using the < ce:doi» tag; • publication date using the < publicationdate> 口 tag and convert it to a datetime object in the format YYYY-MM-DD : • title using the < titletext> L tag; • abstractusing the ‹ce:para> tag.2. Save all these values in a dataframe with columns doi publication_date | 口 title ロ and abstract U. 3. The function structure_data should return a dataframe with the following columns: • doi U : a character column with the Dol; • publication_date • : a date column with the publication date in the format YYYY-MM-DD ロ: title • : a character column with the title; abstract •: a character column with the abstract.
All allowed packages have been loaded in the initial solution. • You may want to parse the XML file to a Python dict • object with the xmltodict.parse() function. • You can use the print() 口 function to debug your solution. Available libraries ・pandas 2.2.3 0 • xmltodict 0.14.2 口
Data structure is very complicated. Looks like this:
('item-info': {'itemidlist': {'ce:doi': '10.1007/00431-007-0495-y*. 'itemid': [('@idtype': 'PUI', '#text': '351238211'). ('@idtype': 'MEDL', '#text': 17516086' /1), 'history': ('date-created': ('@year': '2021', 'month': '03', 'eday': '13'). 'date-aip-loaded': ('@year': '2021' '@month': dbcollection': 'MEDL'), '03", '®day': '16'). 'date-loaded': ('@year': '2021', 'emonth': '03", '®day': 'head': {'citation-info': ('citation-type': ('@code': 'ar'), 'citation-language': ('@xml:lang': 'eng'}, 'abstract-language': ('@xml:lang': 'eng'), 'author-keywords': ('author-keyword': ['Chair-rising test'. 'Maximal isometric grip force', 'Peak jump force', 'Peak jump power'))). 'citation-title': ('titletext': ('@xml:lang': 'eng', '@original': 'y', '#text': 'Mechanogra;' is looking to the left; by'>, to the right, "*, up; or v, down. The guards can see everything in a straight line in the direction in which they are facing, as far as the first obstacle ("X' or any other guard) or the edge of the board. The assassin can move from the current field to any other empty field with a shared edge. The assassin cannot move onto fields containing obstacles or enemies. Write a function: def solution(B) O that, given an array B consisting of N strings denoting rows of the array, returns True if is it possible for the assassin to sneak from their current location to the bottom-right cell of the board undetected, and False Otherwise. Write an efficient algorithm for the following assumptions: • N is an integer within the range [1..500); • all strings in B are of the same length M from range [1..500); • there is exactly one assassin on the board; • there is no guard or wall on B[N-1][M-1]; • every string in B consists only of the following characters", X,', », v, '*' and/or 'A. Given B = [' ... O should return False right at the start. ">. A O 1, your function 口 , as the assassin gets spotted 4. Given B = [A. v O " ... 0 1 your function should return False •. It's not possible for the assassin to enter the bottom-right ell undetected, as the cell is observed. Write an efficient algorithm |