I have a python pandas function that uses some libraries and takes in a couple of parameters. I was wondering if it is possible to convert a python function with parameters to an application (so, .exe file). Would pyinstaller do the trick in this case?
Here is the code for my function:
import math
import statistics
import pandas as pd
import numpy as np
from scipy.stats import kurtosis, skew
from openpyxl import load_workbook
def MySummary(fileIn, MyMethod):
DF = pd.read_csv(fileIn)
temp = DF['Vals']
if (MyMethod == "mean"):
print("The mean is " + str(statistics.mean(temp)))
elif (MyMethod == "sd"):
print("The standard deviation is " + str(temp.std()))
elif (MyMethod == "Kurtosis"):
print("The kurtosis is " + str(kurtosis(temp)))
else:
print("The method is not valid")
What will happen if this gets converted to an .exe file. Will it automatically request arguments for the function MySummary or something like that?
using the argparse module
import argparse
...
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Calculate stats: mean, sd, Kurtosis")
parser.add_argument('fileIn', help="input .csv file")
parser.add_argument('MyMethod', help="stats method")
args = parser.parse_args()
MySummary(args.fileIn, args.MyMethod)
[references][1]
[1]: https://docs.python.org/3/library/argparse.html