I have a long list of pandas transformation commands that I need to run against a pandas DataFrame:
pd['newvar_A'] = pd['somevar'] * pd['somevar']
pd['newvar_C'] = pd['somevar'] * pd['somevar']
pd['newvar_D'] = pd['somevar'] * pd['somevar']
pd['newvar_ETC'] = pd['somevar'] * pd['somevar']
It's a long list (about 150 lines). Is it possible to include this as a separate script called transformations.py
in an already existing script? The idea is to keep the main script simple, so my idea is the script to look like this:
import pandas as pd
pd.read_csv ('data.csv')
...
#Run transformations
insert file = "transformations.py"
...
#rest of the main script
Is there a Python command to call another Python script (assuming this script is located in the same folder as the working directory)?
Thanks!