Linked Questions

1716 votes
44 answers
2.4m views

I want to write a function in Python that returns different fixed values based on the value of an input index. In other languages I would use a switch or case statement, but Python does not appear ...
Michael Schneider's user avatar
17 votes
4 answers
54k views

I have a relatively large DataFrame object (about a million rows, hundreds of columns), and I'd like to clip outliers in each column by group. By "clip outliers for each column by group" I mean - ...
ytsaig's user avatar
  • 3,306
7 votes
1 answer
7k views

I am using the following code to normalize a pandas DataFrame: df_norm = (df - df.mean()) / (df.max() - df.min()) This works fine when all columns are numeric. However, now I have some string columns ...
Edamame's user avatar
  • 25.6k
2 votes
2 answers
6k views

I am trying to bound every value in a dataframe between 0.01 and 0.99 I have successfully normalised the data between 0 and 1 using: .apply(lambda x: (x - x.min()) / (x.max() - x.min())) as follows: ...
densekernel's user avatar
  • 1,361
3 votes
1 answer
7k views

I have a dataframe: Time Weight 1 4 2 2 3 1 4 7 How can I normalize the weight column, so that the sum of the values in the weight column are equal to 1 ?
tj judge 's user avatar
3 votes
1 answer
7k views

I took sample code from sklearn website, which is tuned_parameters = [{'kernel': ['rbf'], 'gamma': [1e-3, 1e-4], 'C': [1, 10, 100, 1000]}, {'kernel': ['linear'], 'C': [1, 10, 100, 1000]}] ...
fspirit's user avatar
  • 2,547
1 vote
1 answer
7k views

I would like to normalise this value in the range of 0 to 100. I have these values in a pandas dataframe. Latitude Longitude 25.436596 -100.887300 25.436596 -100.887700 25....
user3447653's user avatar
  • 4,228
3 votes
2 answers
4k views

I am trying to scale a pandas or numpy array from 0 to a unknown max value with the defined number replaced with 1. One solution I tried is just dividing the defined number I want by the array. test ...
BillyRay's user avatar
  • 413
1 vote
2 answers
4k views

I tried to use the following code to normalize a column in python data frame: df['x_norm'] = df.apply(lambda x: (x['X'] - x['X'].mean()) / (x['X'].max() - x['X'].min()),axis=1) but got the following ...
Edamame's user avatar
  • 25.6k
2 votes
2 answers
3k views

I have a code to normalise data imported from xls. which is a s follows import numpy as np Xt, Tt = XLSImport('AI_sample.xlsx') # calculate the maximum values valX1_max = np.max((Xt)[0]) valX2_max = ...
Sandy.Arv's user avatar
  • 605
0 votes
2 answers
4k views

I'm creating a GUI where there is live 'point in time' data for several records ("things") and fields. records are comparable based on field, but fields are not necessarily related (at least not on ...
Vlox's user avatar
  • 729
-1 votes
1 answer
2k views

I was normalizing the .csv (labelled) and i was following the answer given on this link: Normalize data in pandas So, my question is how do i preserve labels and normalize the data. csv file: ...
Ankit G.'s user avatar
0 votes
1 answer
743 views

For a two-dimensional array, I'm trying to make a standardize-function, which should work row-wise and column-wise. I'm not sure what to do when an argument is given with axis=1 (row-wise). def ...
lvdp's user avatar
  • 5
0 votes
1 answer
364 views

I have a dataframe O D counts 0 G1 G1 8576 1 G1 G2 4213 2 G1 G3 8762 3 G2 G1 8476 4 G2 G2 2134 ... But each of the groups have different populations in O and D. ...
Dervin Thunk's user avatar
  • 20.2k
0 votes
0 answers
432 views

I'm trying to write my first simple neural net with my own data based on various tutorials and information. I'm stuck at the point where I think I prepared the model and I'm trying to run it, but when ...
jwitos's user avatar
  • 502

15 30 50 per page