pandas中不同列的不同填充方法(Different fill methods for different columns in pandas)
我正在以标准方式重新索引数据帧,即
df.reindex(newIndex,method='ffill')
但我意识到我需要逐列地处理丢失的数据。 也就是说,对于某些我希望填充的列,但对于其他列,我希望丢失记录为NA的值。
为简单起见,假设我想要填充的X列,以及我希望NA填充的Y列。 我如何调用.reindex来完成此任务?
I'm reindexing a dataframe in the standard way, i.e.
df.reindex(newIndex,method='ffill')
But realized I need to handle missing data differently on a column-by-column basis. That is, for some columns I want to ffill, but for others I want to missing values recorded as NAs.
For simplicity, let's say I have column X that I want ffilled, and column Y that I want NA-filled. How can I call .reindex to accomplish this?
原文:https://stackoverflow.com/questions/19696017
更新时间:2023-04-01 19:04
最满意答案
您可以使用Selenium Webdriver Functions。
.clearValue( 'input[id=patientId]') .setValue( 'input[id=patientId]', 'your_text')
You can use Selenium Webdriver Functions for this.
.clearValue( 'input[id=patientId]') .setValue( 'input[id=patientId]', 'your_text')
相关问答
更多-
您应该像这样编写页面加载方法代码: protected void Page_Load(object sender, EventArgs e) { if(IsPostBack) return; UpdateBinding(); } 在您的代码中编辑的数据会因编辑代码而失败,因为当您单击“保存”按钮时,首先会执行页面加载,并将列表视图与旧数据绑定(UpdateBinding),然后执行i_UserLV_ItemUpdating。 断点将 ...
-
单击要编辑的文本框时,光标将显示在文本的左侧(When clicking on textbox to edit, cursor appear at left side of text)[2021-04-04]
uff ..我发现错误是什么。 首先,我要感谢大家为我的探索找到解决方案所做的努力。 当mdiContainer称为XPExplorerBar时,我使用了第三方控件。 在@CodyGray建议我在一个新项目中重新编写之后,我做了它并且它工作了(但是因为我只编写了一个没有mdiParent的widnow),然后我添加了一个窗口形式作为mdiContainer它工作了! 谢谢! uff.. I found what the error was. First of all I want to thanks you ... -
ReactJS无法编辑通过状态变量创建的文本框(ReactJS unable to edit the textbox created through state variable)[2023-05-29]
您错过了输入的关闭标记,并且由于您从状态传递值,输入变为只读状态。 因此,请尝试使用defaultValue而不是value来使其可编辑。 You are missing the close tag of input and since you are passing value from the state the input becomes read-only. So try defaultValue instead of value to make it editable. -
你在检查page_load中的IsPostBack属性吗? 或者,无论是否有回发,您所概述的代码都会运行? 如果代码运行而不管回发,那么你正在做的是在Button2_Click有机会访问它们之前覆盖TextBox值。 这是因为在事件处理之前运行Load的页面生命周期 。 如果它不是回发(即用户没有单击提交按钮),您可能只希望page_load中的数据库检索运行,例如: if (!Page.IsPostBack) { using (SqlConnection conn = new SqlConnect ...
-
您是否尝试在aspx代码中将ReadOnly设置为true?我认为vba控件有两个属性可以导致这种情况。 已锁定并已启用。 文本框是否已启用? I think vba controls have two properties which can cause this. Locked and Enabled. Is the textbox enabled?你的问题是一些问题。 首先,你想要使用键值来获得值,否则它会在键值被设置之前触发,并且在被调用时不会给出准确的值。 其次,正在运行的正则表达式正在运行,而您仍然可以输入哪个强制光标到最后。 你可以用计时器来克服这个问题( 从这个答案中借用 )。 试试下面的片段,我相信这会完成你所追求的目标。 var typingTimer; //timer identifier var doneTypingInterval = 1000; //time in ms, 1 second fo ...
jQuery中的可编辑文本框(Editable textbox in jQuery)[2022-01-20]
尝试使用contentEditable属性 $(".double").get(0).contentEditable = "true"; contenteditable属性是枚举属性,其关键字为空字符串,true和false。 空字符串和true关键字映射到true状态。 false关键字映射到false状态。 此外,还有第三个状态,即继承状态,它是缺省值缺省值(默认值无效)。 DEMO1 | DEMO2 Try to use contentEditable attribute $(".double").g ...相关文章
更多- 如果我想让eclipse中重写的方法参数自动填充怎么设置
- RCFileInputFormat的使用方法
- 使用shell命令给文件中每一行的前面、后面、指定列添加字符
- 关于android自动适应机型分辨率和旋转绘制图片帧的问题.
- Diffusion Particle Resolver
- JasperReport填充报表
- 关于Thread类中的start()方法和run()方法
- SQLiteOpenHelper 类中的onCreate方法
- 微信刮刮卡的坑
- JasperReport报表填充参数
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)