从列中填写NAN值,并用另一列中的值填充值
我正在使用一个时间序列数据集,该数据集的兴趣列是“月”列(MES),年份列(ANO),最低价格(最低)和模式价格(MCOM)。
从2013年开始的几个月中,最小列中没有任何价值,在那个月中,想填充MCOM列中的值。
我使用以下行来找到没有最小值的几个月:
dfc.loc[(dfc['ano'] == 2013) & (dfc['mes'] == 1)]
时填充“ mcom”列中的值
dfc['ano'] == 2013 & dfc['mes'] == 1
基本上,我想在我该怎么做
?这就是数据框的负责人:
data dia mes ano wday prod und proc tipo min mcom max merc date julian
6 02/01/2013 2 1 2013 quarta Peixe de agua salgada Kg RS-SC Sardinha NaN 5.28 5.28 Est 2013-01-02 12:00:00 1.416667
14 03/01/2013 3 1 2013 quinta Peixe de agua salgada Kg RS-SC Sardinha NaN 5.28 5.28 Est 2013-01-03 12:00:00 2.416667
22 04/01/2013 4 1 2013 sexta Peixe de agua salgada Kg RS-SC Sardinha NaN 5.28 5.28 Est 2013-01-04 12:00:00 3.416667
30 07/01/2013 7 1 2013 segunda Peixe de agua salgada Kg RS-SC Sardinha NaN 5.28 5.28 Est 2013-01-07 12:00:00 6.416667
38 08/01/2013 8 1 2013 nan Peixe de agua salgada Kg RS-SC Sardinha NaN 5.28 5.28 Est 2013-01-08 12:00:00 7.416667
“ tipo” variabl,只有“ sardinha”,变量的类型为:
dfc.dtypes
data object
dia int64
mes int64
ano int64
wday object
prod object
und object
proc object
tipo object
min float64
mcom float64
max float64
merc object
date object
julian float64
dtype: object
I'm working with a time-series dataset whose my interest columns are the month column (mes), the year column (ano), the minimum prices (min) and the modal price (mcom).
some months from the year 2013 doesn't have any value in the min column, and in those months and want to fill with the values that are in the mcom column.
I used the following line to find the months where there are no min values:
dfc.loc[(dfc['ano'] == 2013) & (dfc['mes'] == 1)]
Basically, I want to fill the 'min' column with the values in the 'mcom' column when
dfc['ano'] == 2013 & dfc['mes'] == 1
how can I do it?
That's the head of the dataframe:
data dia mes ano wday prod und proc tipo min mcom max merc date julian
6 02/01/2013 2 1 2013 quarta Peixe de agua salgada Kg RS-SC Sardinha NaN 5.28 5.28 Est 2013-01-02 12:00:00 1.416667
14 03/01/2013 3 1 2013 quinta Peixe de agua salgada Kg RS-SC Sardinha NaN 5.28 5.28 Est 2013-01-03 12:00:00 2.416667
22 04/01/2013 4 1 2013 sexta Peixe de agua salgada Kg RS-SC Sardinha NaN 5.28 5.28 Est 2013-01-04 12:00:00 3.416667
30 07/01/2013 7 1 2013 segunda Peixe de agua salgada Kg RS-SC Sardinha NaN 5.28 5.28 Est 2013-01-07 12:00:00 6.416667
38 08/01/2013 8 1 2013 nan Peixe de agua salgada Kg RS-SC Sardinha NaN 5.28 5.28 Est 2013-01-08 12:00:00 7.416667
The 'tipo' variabl, only has 'sardinha' and the types of the variables are:
dfc.dtypes
data object
dia int64
mes int64
ano int64
wday object
prod object
und object
proc object
tipo object
min float64
mcom float64
max float64
merc object
date object
julian float64
dtype: object
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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