AttributeError: ‘float’ object has no attribute ’round’
Just change this: a = 3.56803 print(a.round(2)) to this: a = 3.56803 print(round(a, 2))
Just change this: a = 3.56803 print(a.round(2)) to this: a = 3.56803 print(round(a, 2))
The simple code would be: df.index[condition] so something like this: df.index[df[‘column1’] == True].tolist() .tolist() is used when there are multiple values match the condition
.item() will do the job: p1 = df[df[“column2”]==df.column2.max()].column1.item() print(p1) This way you can extract the actual value from pandas dataframe and store it in variable for later use.
Hello. I have been using np.arrange for a long time but only now I have noticed that this built-in function doesn’t include the last maximum value. Like for example: step = 2 print(np.arange(0, 26, step)) results in [0 2 4 6 8 10 12 14 16 18 20 22 24] So how do we make … Read more
Here’s my example: params = { ‘param1’: [[25, 30, 35],[-25, -30, -35]], ‘param2’: [[20, 25, 30],[-20, -25, -30]] } for key, value in paramsNEW.items(): print( key, value[0], value[1] ) for v in value: print(v) for key, value in paramsNEW.items(): print(key, [(v1,v2) for v1 in value[0] for v2 in value[1]])
In a normal njit function setting error_model=”numpy” does exactly this. There are also significant speedups possible by setting this option. So: @njit(error_model=”numpy”) If you are wandering what Numba is, read more about Numba here. It’s a really cool thing, I highly recommend getting familiar with it.
from sklearn.preprocessing import MinMaxScaler scaler = MinMaxScaler(feature_range=(0,1)) a = df.to_numpy() a = scaler.fit_transform(a)
Here’s a good example to understand quantiles in python: import numpy as np d = [1, 1.2, 1.5, 2, 6, 7, 22, 3] q = 0.99 qr = np.quantile(d, q) print(f”{q*100}% less than {qr}”)
Here we calculate 0.9th quantile of each column in our dataframe: q = 0.9 for column in df: qr = df[column].quantile(q) print(f”{q*100}% are lower than {qr}”) Here’s a good example to understand quantiles.
Make sure you convert column to Date & Time properly before calling dt.strftime(): df[‘NewDateTime’] = pd.to_datetime(df.DateTime).dt.strftime(“%d/%m/%Y %H:%M”)