I have a list of numbers and i want to fill those numbers in the cells of pandas data frame. For instance,
Lst=[216516.61000000002,
214771.62000000002,
213026.63000000003,
211281.64000000004,
209536.65000000005,
207791.66000000006,
206046.67000000007,
204301.68000000008,
202556.6900000001]
and dataframe
I want to fill each numbers from the list Lst individually to the index number #131 of the data frame such as 216516.61000000002 needs to fill in the column name "2001" and index #131, 214771.62000000002 to Column name "2002" and index #131 and so on..
You can access the row by using loc
and reuse loc
to get only a part of this row, then replace this row by a Series
with the right data
and index
:
df.loc[0].loc[2001:] = pd.Series(data=Lst, index=[2001,...])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.