Skip to content

Latest commit

 

History

History
15 lines (13 loc) · 499 Bytes

1148. Article Views I.md

File metadata and controls

15 lines (13 loc) · 499 Bytes

1148. Article Views I

Question Link

Solution

import pandas as pd

def article_views(views: pd.DataFrame) -> pd.DataFrame:
    result1=views[views['author_id']==views['viewer_id']]
    result1=sorted(result1['author_id'].unique())
    # after the sorted function, the result1 has been turned to list, but the dataframe.
    # need to compose a dataframe with result again
    result=pd.DataFrame({'id':result1})

    return result