Categories
Mastering Development

Group by and update value based on another column using python

I have a data frame with below columns, using which need to create new columns by grouping Name. Status should be updated as active to entire group if it is active for any one St. data = {‘Name’:[‘Tom’, ‘Tom’, ‘krish’, ‘jack’,’jack’,’Nam’,’sue’], ‘St’:[‘S-123’, ‘S-290’, ‘S-123’, ‘S-147′,’S-98′,’S-123′,’S-38’], ‘Status’:[‘Inactive’,’active’,’active’,’inactive’,’active’,’Inactive’,’Inactive’]} df = pd.DataFrame(data) The desired output is Name St […]

Categories
Mastering Development

how to get GeoLocation in Movilizer?

In one of my use case, I need the current address(Geolocation) of my mobile device. How to get current Geolocation in Movilizer. Anyone knows, Please let me know Thanks, Krish

Categories
Mastering Development

Substitute in column of dataframe if the integer values meet certain criteria [duplicate]

Instead of having Age in numbers, I need to group them by certain age groups that get substituted on the data frame import pandas as pd # intialise data of lists. data = {‘Name’:[‘Tom’, ‘nick’, ‘krish’, ‘jack’,’Ann’,’James’], ‘Age’:[20, 21, 45, 58,34,60]} # Create DataFrame df = pd.DataFrame(data) This is what I tried: if df[‘Age’] < […]

Categories
Mastering Development

How to parse the @message in aws insight [closed]

@message is ((1, ‘Admin’, ‘Krish’, ‘KTR’, ‘1,2’, 8, ‘KCR’),) log from lambda function then how to parse this and get separate fields like 1 or Admin or Krish or KTR

Categories
Development

Pandas groupby on one column witout losing others columns?

I have a problem with the groupby and pandas, at the beginning I have this chart : import pandas as pd data = {‘Code_Name’:[1,2,3,4,1,2,3,4] ,’Name’:[‘Tom’, ‘Nicko’, ‘Krish’,’Jack kr’,’Tom’, ‘Nick’, ‘Krishx’, ‘Jacks’],’Cat’:[‘A’, ‘B’,’C’,’D’,’A’, ‘B’,’C’,’D’], ‘T’:[9, 7, 14, 12,4, 3, 12, 11]} # Create DataFrame df = pd.DataFrame(data) df i have this : Code_Name Name Cat T […]

Categories
Development

Merge 2 rows in Pandas based on a given condition in a column

How to merge 2 cells in the Pandas dataframe when one of the cells of the other column is empty lst = [[‘tom’, ‘reacher’, 25], [‘krish’, ‘pete’, 30], [”, ”, 26], [‘juli’, ‘williams’, 22]] df = pd.DataFrame(lst,columns=[‘FName’,’LName’,’Age’],dtype=float) In [4]:df Out[4]: FName LName Age 0 tom reacher 25.0 1 krish pete 30.0 2 26.0 3 juli […]