[PYTHON] How to reassign index in pandas dataframe

The index may be disturbed while manipulating the dataframe such as deleting rows or joining. In this case, if you want to reassign the index from 0, use reset_index (drop = True).

reset_index.py


    rssi_data = rssi_data.reset_index(drop=True)

Example

before.py


 print window_data.head()
               t   dist(8)   dist(9)  dist(10)  dist(11)  dist(12)
13  12:55:26.600  2.362109  2.369736  2.031889  1.240509  0.860399
14  12:55:26.800  2.336146  2.385064  1.986095  1.210598  0.847227
15  12:55:27.000  2.312065  2.412682  1.936422  1.180321  0.835603
16  12:55:27.200  2.289813  2.441181  1.891472  1.154516  0.823569
17  12:55:27.400  2.269342  2.470586  1.850973  1.132922  0.811148

index reassignment

after.py


 window_data = window_data.reset_index(drop=True)
 print window_data.head()
              t   dist(8)   dist(9)  dist(10)  dist(11)  dist(12)
0  12:55:26.600  2.362109  2.369736  2.031889  1.240509  0.860399
1  12:55:26.800  2.336146  2.385064  1.986095  1.210598  0.847227
2  12:55:27.000  2.312065  2.412682  1.936422  1.180321  0.835603
3  12:55:27.200  2.289813  2.441181  1.891472  1.154516  0.823569
4  12:55:27.400  2.269342  2.470586  1.850973  1.132922  0.811148

Recommended Posts

How to reassign index in pandas dataframe
How to get a specific column name and index name in pandas DataFrame
How to read CSV files in Pandas
python / pandas / dataframe / How to get the simplest row / column / index / column
How to use Pandas 2
Convert comma-separated numeric strings to numbers in Pandas DataFrame
How to access with cache when reading_json in pandas
How to use Pandas Rolling
How to display DataFrame as a table in Markdown
I tried to summarize how to use pandas in python
How to develop in Python
Export pandas dataframe to excel
Put the lists together in pandas to make a DataFrame
A handy function to add a column anywhere in a Pandas DataFrame
How to set the extended iso8601 format date to the Dataframe index
How to get an overview of your data in Pandas
How to create dataframes and mess with elements in pandas
Data science companion in python, how to specify elements in pandas
[Python] How to do PCA in Python
How to handle session in SQLAlchemy
How to use classes in Theano
[Python] How to use Pandas Series
How to collect images in Python
How to update Spyder in Anaconda
How to use SQLite in Python
How to convert 0.5 to 1056964608 in one shot
How to reflect CSS in Django
How to kill processes in bulk
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to run TensorFlow 1.0 code in 2.0
How to handle Japanese in Python
How to log in to Docker + NGINX
How to call PyTorch in Julia
How to find out if there is an arbitrary value in "somewhere" of pandas DataFrame
[Python] How to add rows and columns to a table (pandas DataFrame)
How to find the memory address of a Pandas dataframe value
<Pandas> How to handle time series data in a pivot table
I will explain how to use Pandas in an easy-to-understand manner.
How to use calculated columns in CASTable
[Python] Summary of how to use pandas
[Introduction to Python] How to use class in Python?
How to suppress display error in matplotlib
How to split and save a DataFrame
How to access environment variables in Python
How to dynamically define variables in Python
[Pandas] What is set_option [How to use]
How to do R chartr () in Python
How to convert csv to tsv in CLI
How to delete expired sessions in Django
[Itertools.permutations] How to put permutations in Python
How to use Google Test in C
How to implement nested serializer in drf-flex-fields
How to work with BigQuery in Python
How to execute commands in jupyter notebook
How to do'git fetch --tags' in GitPython
How to get a stacktrace in python
How to display multiplication table in python
How to extract polygon area in Python