如何将Python代码插入另一个文件上的函数中?
晚上好,我一直在研究一些自动化软件,并且遇到了一些障碍,因此我需要从旧数据框架中创建一个数据框架。但是,我的问题是self.new_df行需要进入单独的文件。这些线的数量需要模块化,并根据情况而变化。示例:
file_1
class mapping:
__def__(self,new_df,df)):
xxxxxxxxxxxxxxxx
def map_df():
self.new_df['column1'] = ''
self.new_df['column2'] = self.df['column2b']
self.new_df['column3'] = VARIABLE_ONE
需要变成:
file_1
import file_2 as f2
class mapping:
__def__(self,new_df,df,block_quote):
xxxxxxxxxxxxxxxxx
def map_df():
f2.block_quote
file_2
block_quote =
self.new_df['column1'] = ''
self.new_df['column2'] = self.df['column2b']
self.new_df['column3'] = VARIABLE_ONE
长篇小说,我是唯一一个知道python的人,所以我们需要一个文件才能保持不变,而另一个文件只是存储变量,词典以及偶尔的函数,以便容易适用于没有Python经验的人可以更新映射。感谢您的帮助!
Good evening, I've been working on some automation software and I have hit a little snag, so I need to create a dataframe from an old dataframe. However, my problem is that the self.new_df lines need to go into a separate file. The number of these lines needs to be modular and change depending on circumstance. example:
file_1
class mapping:
__def__(self,new_df,df)):
xxxxxxxxxxxxxxxx
def map_df():
self.new_df['column1'] = ''
self.new_df['column2'] = self.df['column2b']
self.new_df['column3'] = VARIABLE_ONE
Needs to turn into:
file_1
import file_2 as f2
class mapping:
__def__(self,new_df,df,block_quote):
xxxxxxxxxxxxxxxxx
def map_df():
f2.block_quote
file_2
block_quote =
self.new_df['column1'] = ''
self.new_df['column2'] = self.df['column2b']
self.new_df['column3'] = VARIABLE_ONE
Long story short, I am the only one who knows python so we need one file to remain untouched and another just to store variables, dictionaries, and perhaps the occasional function so that it is easy for someone without python experience could update the mappings. Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试执行
或生成功能t
Try doing
or generate a function t