熊猫使用默认的非nan值与重叠的列名合并在一起
有一个以CSV格式指定的表和一些配置列表。
我想从 configs 中使用默认配置,并在 tables 中覆盖它,如果需要,
configs = """
schema|new_name
dbo|{table}
qa|test_{table}
"""
tables = """
table|schema|new_name
employee|hr|{schema}_{table}
advertisers
users
"""
configs = pandas.read_csv(io.StringIO(configs), sep='|')
tables = pandas.read_csv(io.StringIO(tables), sep='|')
我想交叉加入/merge/concatenate/compateNate/combine combine combine compline compline/combine ythem todef sughem togationframe。
final = """
table|schema|new_name
employee|hr|{schema}_{table}
advertisers|dbo|{table}
users|dbo|{table}
employee|hr|{schema}_{table}
advertisers|qa|test_{table}
users|qa|test_{table}
"""
如果未指定架构,请使用“ DBO”模式和“用户/广告商”表名。
如果指定模式,请使用“ HR”模式和“ HR_Employee”表名。
基本上 - 当2行带有重叠列名称的水平凸进时,请使用一个不是NAN的值创建一个列。
我应该使用什么熊猫命令?
There is a list of tables and some configurations, specified in csv format.
I want to use default configuration from configs, and override it in tables if needed
configs = """
schema|new_name
dbo|{table}
qa|test_{table}
"""
tables = """
table|schema|new_name
employee|hr|{schema}_{table}
advertisers
users
"""
configs = pandas.read_csv(io.StringIO(configs), sep='|')
tables = pandas.read_csv(io.StringIO(tables), sep='|')
I want to cross-join/merge/concatenate/combine them to get a dataframe which contains:
final = """
table|schema|new_name
employee|hr|{schema}_{table}
advertisers|dbo|{table}
users|dbo|{table}
employee|hr|{schema}_{table}
advertisers|qa|test_{table}
users|qa|test_{table}
"""
If schema is not specified, use 'dbo' schema and 'users/advertisers' table name.
If schema is specified, use 'hr' schema and 'hr_employee' table name.
Basically - when horizontal concat of 2 rows with overlapping column names, create one column using whichever value is not NaN.
What pandas command should I use ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:
EDIT: