Let TimeAndValue be pd.DataFrame.
CurrentValue = TimeAndValue.tail (1)
As, I took out the data of the last row as CurrentValue in the form of pandas.Series.
print (CurrentValue.iloc [0, 0: 6])
Then, the data of the first 6 data plus indexes will be printed line by line.
However, if you do as below,
print (CurrentValue.iloc [0, 0])
print (CurrentValue.iloc [0, 1])
print (CurrentValue.iloc [0, 2])
print (CurrentValue.iloc [0, 3])
print (CurrentValue.iloc [0, 4])
print (CurrentValue.iloc [0, 5])
print (CurrentValue.iloc [0, 6])
The final print (CurrentValue.iloc [0, 6]) is IndexError: single positional indexer is out-of-bounds.
I don't understand the reason ...
Is it possible to retrieve only the last index without using a different method?
Instead, if it is iloc [0: 6], it will spit out everything without error.
I would appreciate it if you could explain it.
Answer # 1
[0: 6] is a slice from index 0 to index 5. Index 6 is not included in the sliced result.
Index 6 is out of range for an array with only 6 elements.
The same is true for Series.iloc, as described in the list example.
x = [1, 2, 3] print (x [: 2]) # [1, 2], sliced result does not include x 
- i don't understand the exercises using python trigonometric functions
- i don't understand the declaration part of the python code
- [python] i don't understand the meaning of the error
- i don't understand the behavior of the python for statement
- python 3x - select by indexing qlistwidget items
- [python] i don't understand why the code can't be executed
- i was given a python 3 assignment as a cram school assignment, but i don't understand "functions and comprehensions, while
- python - what i don't understand about yolo9000 (v2)
- python - i can't understand the specifications of pandas
- i don't understand the meaning of x used in a python pandas lambda expression
- python - what you do not understand by calculating the precision and recall
- i don't understand the meaning of the python pandas code
- i don't understand python error handling
- i don't understand the reason for syntaxerror when executing python code
- python - i don't understand the meaning of the code
- [python3] make it easier to understand the process of changing the method to be called according to the input (character string)
- python i don't understand the meaning of * (asterisk) in the following cases
- python : Interpret the PERIOD type when inserting in Oracle
- Download a certain form of Excel in Python, add data to it and save in source formatting
- python : Pandas Comparison of two DF and row sample
- python : Select speakers in DataFrame list
- python : Combining several datasherapms without adding columns with prefix
- python : Change the value in the column based on the condition to another column
- python : How from the Data Pandas Data Pandas duplicate lines?
- In Python -Resulting Train Set Will Be Empty: How to "repair" sample size?
- python : Check the value from several speakers of the DATAPHREAM for the presence in the other
- Python Pandas Match the values of the second DataFrame by the values of the first DataFrame in the same order, quantity and