Category : replace

I’ve got 2 Dataframes : df_bisID = pd.DataFrame({‘A’: [‘ID1#ID2’, ‘ID3#ID4’], ‘B’: [‘ID5#ID6’, ‘ID7#ID8’], ‘C’: [‘ID9#ID10’, ‘ID11#ID12’], ‘D’: [‘ID13#ID14’, ‘ID15#ID16’]}) A B C D 0 ID1#ID2 ID5#ID6 ID9#ID10 ID13#ID14 1 ID3#ID4 ID7#ID8 ID11#ID12 ID15#ID16 df_eliminateID = pd.DataFrame({‘A’: [‘ID1’, ‘ID3’, ‘ID9’, ‘ID11’], ‘B’: [‘ID5’, ‘ID7’, ‘ID13’, ‘ID15’]}) A B 0 ID1 ID5 1 ID3 ID7 2 ID9 ..

Read more

I’m trying to replace string in a unstructured list that I moved to one column in pandas dataframe: my_list = [ [‘1001100’, ‘xxx’, ”, ‘1100’, ‘PAR_200’, ‘21651947694’, ‘0’, ‘0’, ‘20210301’, ‘20210331’, ‘1630,51’, ‘1’, ”] [‘1001110’, ‘sss’, ”, ‘1110’, ‘C-200’, ‘20210307’, ‘1630,51’, ‘1’, ‘7252048000136’, ”] [‘1001115’, ‘ddd’, ”, ‘1115’, ’21’, ”, ‘NO6520058050362’, ‘0’, ’08’, ‘110433’, ‘1630,51’, ..

Read more

I am trying to rename a column name with another. However i get a red mark at the end of this line. Does anybody know what could have gone wrong? df.rename(columns={‘oldname’: ‘newname’}, inplace=True) df["NewKey"] = df["key"] + df["name"] I receive a syntax error in pycharm when executing the above code.. Source: Python..

Read more

For an assignment I am creating function remove_extraneous, designed to take in any string and return the string with only letters in the alphabet. Here is my attempt so far: alphabet = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ..

Read more