Issue
I have a scripts (script 1) in python that produce a dataframe
like this one:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.array([[1, 2], [4, 5]]), index=('27-04-2020','28-04-2020'), columns=('Prediction', 'Certainty'))
I want to import the dataframe
into (script A). However, I can not seem to find a way for importing dataframes.
Can someone help me with a solution for this?
Solution
You can simply do this in script_a.py as
from script_1 import df
But a cleaner way to do that would be: In script_1.py
import pandas as pd
import numpy as np
def get_dataframe():
df = pd.DataFrame(np.array([[1, 2], [4, 5]]), index=('27-04-2020','28-04-2020'), columns=('Prediction', 'Certainty'))
In script_a.py
from script_1 import get_dataframe
df = get_dataframe()
Answered By - user2077935
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.