Category : data-science

I have a sample of list of dictionaries as given below NaN = np.nan cols = [ {‘A’:[‘Orange’, ‘Lemon’, NaN, ‘Peach’]}, {‘B’:[‘Tiger’, NaN, NaN, ‘Lion’]}, {‘C’:[‘London’, ‘New York’, ‘Bangalore’, NaN]}, {‘D’:[‘Cricket’, ‘BaseBall’, ‘Football’, ‘Tennis’]} ] I want to convert this to columns of dataframe. The keys of the dictionary should be the column name. The ..

Read more

I have a sample dataframe as given below. import pandas as pd import numpy as np NaN = np.nan data = {‘ID’:[‘A’, ‘A’, ‘A’, ‘B’,’B’,’B’], ‘Date’:[‘2021-09-20 04:34:57’, ‘2021-09-20 04:37:25’, ‘2021-09-20 04:38:26’, ‘2021-09-01 00:12:29′,’2021-09-01 11:20:58′,’2021-09-02 09:20:58’], ‘Name’:[‘xx’,’xx’,NaN,’yy’,NaN,NaN], ‘Height’:[174,174,NaN,160,NaN,NaN], ‘Weight’:[74,NaN,NaN,58,NaN,NaN], ‘Gender’:[NaN,’Male’,NaN,NaN,’Female’,NaN], ‘Interests’:[NaN,NaN,’Hiking,Sports’,NaN,NaN,’Singing’]} df1 = pd.DataFrame(data) df1 I want to combine the data present on the same date ..

Read more