Please help me understand how to approach this problem, I'm a beginner in Python.
I have this specific task where I have to import data from an excel file (.xlsx) and take the column 'Count' to perform normalization in Python.
Then under Numpy library define a function in Python to perform this normalization operation (or any operation in future) and print the output(Normalized result) to a new sheet in the same excel workbook
Is it possible to do this task strictly using numpy?*
[ formula used in excel -> ( =(A2-MIN($A$2:$A$11))/(MAX($A$2:$A$11)-MIN($A$2:$A$11))*10 ) which is to be translated in to a function in python using numpy}
instructions provided to me is as follows:
import numpy as nd
def normalize (x):
""" This function has the logic for normalization
Inputs
------
x: input count
Returns
------
the transformed f(x)
"""
return x
Sample Data:
| Count | Constant |
|---|---|
| 10 | 100 |
| 20 | 100 |
| 30 | 100 |
| 40 | 100 |
| 50 | 100 |
| 60 | 100 |
| 70 | 100 |
| 80 | 100 |
| 90 | 100 |
| 100 | 100 |
This is what I I've coded so far:-
import pandas as pd
import numpy as np
data = pd.read_excel(r"path of file") #import or read excel file
data = data['Count'] #to convert the column into dataframe
data2 = data.to_numpy() #to convert dataframe into numpy array
print(data2)
def normalize(data2):
return ((data2 - min(data2))/(max(data2)-min(data2)))*10
print(normalize(data2))
But this code doesn't seem like to be completely on par with the instructions provided