
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

110 Views
To indicate duplicate index values except for the last occurrence, use the index.duplicated(). Use the keep parameter with the value last.At first, import the required libraries −import pandas as pdCreating the index with some duplicates−index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane'])Display the index −print("Pandas Index with duplicates...", index)Indicate duplicate index values as True, except the last occurrence. Set the "keep" parameter as "last" −print("Indicating duplicate values except the last occurrence...", index.duplicated(keep='last'))ExampleFollowing is the code −import pandas as pd # Creating the index with some duplicates index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane']) # Display the index print("Pandas Index ... Read More

227 Views
To indicate duplicate index values except for the first occurrence, use the index.duplicated(). Use the keep parameter with the value first.At first, import the required libraries −import pandas as pdCreating the index with some duplicates−index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane'])Display the index −print("Pandas Index with duplicates...", index)Indicate duplicate index values as True, except the first occurrence. Set the "keep" parameter as "first" −print("Indicating duplicate values except the first occurrence...", index.duplicated(keep='first'))ExampleFollowing is the code −import pandas as pd # Creating the index with some duplicates index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane']) # Display the index print("Pandas Index ... Read More

759 Views
To indicate duplicate index values, use the index.duplicated() method.At first, import the required libraries −import pandas as pdCreating the indexwith some duplicates −index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane']) Display the index −print("Pandas Index with duplicates...", index)Indicate duplicate index values as True, rest False. By default, it keeps the first occurrence of the duplicate value unmarked −print("Indicating duplicate values...", index.duplicated()) ExampleFollowing is the code −import pandas as pd # Creating the index with some duplicates index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane']) # Display the index print("Pandas Index with duplicates...", index) # Return the dtype of the ... Read More

245 Views
To return Index with duplicate values completely removed, use the index.drop_duplicates() method.At first, import the required libraries −import pandas as pdCreating the indexwith some duplicates −index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane']) Display the index −print("Pandas Index with duplicates...", index)Return Index with duplicate values removed. The "keep" parameter with value "False" drops all occurrences for each set of duplicated entries −print("Index with duplicate values removed (drops all occurrences)...", index.drop_duplicates(keep = False))ExampleFollowing is the code −import pandas as pd # Creating the index with some duplicates index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane']) # Display the index print("Pandas Index ... Read More

274 Views
To return Index with duplicate values removed keeping the last occurrence, use the index.drop_duplicates() method. Use the keep parameter with value last.At first, import the required libraries −import pandas as pdCreating the index with some duplicates−index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane']) Display the index −print("Pandas Index with duplicates...", index)Return Index with duplicate values removed. The "keep" parameter with value "last" keeps the last occurrence for each set of duplicated entries −print("Index with duplicate values removed (keeping the last occurrence)...", index.drop_duplicates(keep='last')) ExampleFollowing is the code −import pandas as pd # Creating the index with some duplicates index = pd.Index(['Car', ... Read More

172 Views
To return Index with duplicate values removed except the first occurrence, use the index.drop_duplicates() method. Use the keep parameter with value first.At first, import the required libraries −import pandas as pdCreating the index with some duplicates −index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane']) Display the index −print("Pandas Index with duplicates...", index)Return Index with duplicate values removed. The "keep" parameter with value "first" keeps the first occurrence for each set of duplicated entries −index.drop_duplicates(keep='first') ExampleFollowing is the code −import pandas as pd # Creating the index with some duplicates index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane']) # Display the ... Read More

341 Views
To make new Index with passed list of labels deleted, use the index.drop() method. Pass the list of labels in it.At first, import the required libraries −import pandas as pdCreating the index −index = pd.Index(['Car', 'Bike', 'Truck', 'Ship', 'Airplane']) Display the index −print("Pandas Index...", index)A list containing labels to be dropped are passed −print("Updated index after deleting labels...", index.drop(['Bike', 'Ship'])) ExampleFollowing is the code −import pandas as pd # Creating the index index = pd.Index(['Car', 'Bike', 'Truck', 'Ship', 'Airplane']) # Display the index print("Pandas Index...", index) # Return the dtype of the data print("The dtype object...", index.dtype) ... Read More

641 Views
To make new Pandas Index with deleting multiple index elements, use the index.delete() method. Set the multiple index elements in it.At first, import the required libraries −import pandas as pdCreating the index −index = pd.Index([15, 25, 35, 45, 55, 75, 95])Display the index −print("Pandas Index...", index)Deleting multiple indexes at 3rd position i.e. index 2 and 5th position i.e. index 4 −print("Remaining Index after deleting multiple index elements...", index.delete([2, 4]))ExampleFollowing is the code −import pandas as pd # Creating the index index = pd.Index([15, 25, 35, 45, 55, 75, 95]) # Display the index print("Pandas Index...", index) # ... Read More

100 Views
To make new Pandas Index with passed location deleted, use the index.delete() method.At first, import the required libraries −import pandas as pdCreating the index −index = pd.Index([15, 25, 35, 45, 55]) Display the index −print("Pandas Index...", index)Deleting a single index at 3rd position i.e. index 2 −print("Remaining Index after deleting an index at location 3rd (index 2)...", index.delete(2)) ExampleFollowing is the code −import pandas as pd # Creating the index index = pd.Index([15, 25, 35, 45, 55]) # Display the index print("Pandas Index...", index) # Return the number of elements in the Index print("Number of elements in ... Read More

124 Views
To return the int position of the largest value in the Index, use the index.argmax() method.At first, import the required libraries −import pandas as pdCreating the index −index = pd.Index([15, 25, 55, 10, 100, 70, 35, 40, 55]) Display the index −print("Pandas Index...", index)Get the int position of the largest value in the Index −print("Get the int position of the largest value in the Index...", index.argmax()) ExampleFollowing is the code −import pandas as pd # Creating the index index = pd.Index([15, 25, 55, 10, 100, 70, 35, 40, 55]) # Display the index print("Pandas Index...", index) # ... Read More