How to use 'pandas reset index to start at 0' in Python

Every line of 'pandas reset index to start at 0' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
131def reset(self, start_date=None):
132 if self._is_test:
133 self._gen_df = load_pickles_and_reorder(self.data_path + "/gen_caiso_test.pkl")
134 self._dem_df = load_pickles_and_reorder(self.data_path + "/dem_caiso_test.pkl")
135 else:
136 self._gen_df = load_pickles_and_reorder(self.data_path + "/gen_caiso_train.pkl")
137 self._dem_df = load_pickles_and_reorder(self.data_path + "/dem_caiso_train.pkl")
138
139 if start_date is not None:
140 self._start_date = start_date
141 else:
142 self._start_date = pd.to_datetime(self._gen_df['timestamp'].values[0])
143 self._date = self._start_date
144 self._state = np.array([0, self._date.hour])
145 return self._get_obs()
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

653def set_index_post_series(df, index_name, drop, column_dtype):
654 df2 = df.drop("_partitions", axis=1).set_index("_index", drop=True)
655 df2.index.name = index_name
656 df2.columns = df2.columns.astype(column_dtype)
657 return df2

Related snippets