analytics

Find the min/max in a pandas data column wth nans in between

Find the min/max in a pandas data column wth nans in between Question: I have a pandas data-frame with a column named "Outside Dead Band", the data is recorded at 32Hz (32 data points per second). I want to follow the follwing algorithm. Between 2 nans in the data column, check The duration of no …

Total answers: 1

How to amend defined function to calculate wanted output (Pandas)

How to amend defined function to calculate wanted output (Pandas) Question: I am trying to calculate the following ‘new_field’ column by triple looping through the ‘name’, ‘val_id’ and ‘fac_id’ column with the following conditions. 1.Within each ‘val_id’ loop if ‘product’ == ‘CL’ then min of ‘val_against’ and ‘our_val_amt’ e.g. min( val_against (134), our_val_amt (424)) therefore …

Total answers: 1

Polars equivalent of pandas expression df.groupby['col1','col2']['col3'].sum().unstack()

Polars equivalent of pandas expression df.groupby['col1','col2']['col3'].sum().unstack() Question: pandasdf=pd.DataFrame( { "A": [1, 2, 3, 4, 5], "fruits": ["banana", "banana", "apple", "apple", "banana"], "B": [5, 4, 3, 2, 1], "cars": ["beetle", "audi", "beetle", "beetle", "beetle"], "optional": [28, 300, None, 2, -30], } ) pandasdf.groupby(["fruits","cars"])[‘B’].sum().unstack() How can i create an equivalent truth table in polars? Something like the …

Total answers: 1

Get part of day (morning, afternoon, evening, night) in Python dataframe

Get part of day (morning, afternoon, evening, night) in Python dataframe Question: Here is my dataframe , I need to create a new column based on the timehour which the row value be like (morning, afternoon, evening, night) Here is my code if ((prods[‘hour’] < 4) & (prods[‘hour’] > 8 )): prods[‘session’] = ‘Early Morning’ …

Total answers: 2

XGBoost XGBClassifier Defaults in Python

XGBoost XGBClassifier Defaults in Python Question: I am attempting to use XGBoosts classifier to classify some binary data. When I do the simplest thing and just use the defaults (as follows) clf = xgb.XGBClassifier() metLearn=CalibratedClassifierCV(clf, method=’isotonic’, cv=2) metLearn.fit(train, trainTarget) testPredictions = metLearn.predict(test) I get reasonably good classification results. My next step was to try tuning …

Total answers: 5