I have a problem assigning values to a dataframe at a specific location (column and index). First I create an empty dataframe:
self.timeseries = pd.DataFrame(
columns = ["temperature", "state_of_charge", "m_ice", "m_water"],
index = pd.date_range(
start = self.environment.start,
end = self.environment.end,
freq = self.environment.time_freq,
name = "time"
)
)
Later I try to assign values to each column for each index:
self.timeseries.temperature.loc[timestamp] = self.current_temp
self.timeseries.state_of_charge.loc[timestamp] = self.state_of_charge
self.timeseries.m_ice.loc[timestamp] = self.m_ice /self.mass
self.timeseries.m_water.loc[timestamp] = self.m_water / self.mass
the first line of the code above seems to work. But once it reaches the second line, I get the following error message:
ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'>
In other parts of the code exactly the same procedure is used, and it works.
Many thanks for each help in advance!
P.S.: I dont know, if it is necessary, but additional info:
I work with spyder 3.3.6 (Python 3.7) in anaconda 1.9.12