检查是否存在列,如果不添加
我有一系列非耗尽的数据范围。在清洁过程中,我想循环浏览数据框架,并检查某些列是否存在以及是否不存在它们。我一生都无法找到一种方法来做到这一点。我不害羞,更喜欢它们而不是基础。
任何方向都非常感谢。
I have a series of dataframes that are noncumulative. During the cleaning process I want to loop through the dataframe and check if certain columns exists and if they aren't present create them. I can't for the life of me figure out a method to do this. I am not package shy and prefer them to base.
Any direction is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用此虚拟数据
df
和coltoadd
列以检查是否不存在添加,然后应用该列是否存在
null
产生的您的列Egrnorm(5)
You can use this dummy data
df
andcolToAdd
columns to check if not exists to addthen apply the check if the column exists
NULL
produced else add your column e.g.rnorm(5)