i have a data from in abc.py i want read the dataframe(DB) in another file xyz.py and perform some other operation
in xyz.py
import abc as abc print(abc.DB) its giving empty data frame.
Need a solution how to access a DataFrame in multiple files.
You can make it work by having the following: abc.py
:
import pandas as pd
df = pd.DataFrame([[0, 0, 0], [1, 1, 1], [2, 2, 2]], ["one", "two", "three"])
xyz.py
:
# you could also write "from test import df"
from test import *
print(df)
The output I get from running xyz.py
is this, just as expected:
0 1 2
one 0 0 0
two 1 1 1
three 2 3 4
This should work for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.