如何在功能中添加后缀?
我想创建一个预处理功能,该功能将在数据框架名称中添加后缀。
这将使我可以轻松地识别我的数据范围,而无需或使用功能缩放和使用的技术(如果适用)。
例如:
mas = MaxAbsScaler()
def preproce_MaxAbsScaler(df):
[df+str("_mas")]=pd.DataFrame(mas.fit_transform(df),
index=df.index,
columns=df.columns)
return [df+str("_mas")]
I want to create a preprocessing function that would add a suffix to the dataframe name.
This will allow me to easily identify my dataframes without or with feature scaling and the technique used if applicable.
For example:
mas = MaxAbsScaler()
def preproce_MaxAbsScaler(df):
[df+str("_mas")]=pd.DataFrame(mas.fit_transform(df),
index=df.index,
columns=df.columns)
return [df+str("_mas")]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
其中包含函数内部功能的变量名称,请考虑
导致
您可以选择仅设置
pandas.dataframe
不是方法或列的名称,例如然后以正常方式使用实例属性访问
Variables names inside function are contained therein, consider that
lead to
You might elect to just set attribute of
pandas.DataFrame
which is not name of method or column thereof, for exampleand then access in normal way of using instance attributes
使用
add_suffix
解决此问题:Use
add_suffix
to solve this issue: