Index.copy() makes a copy of this object. The function also sets the name and dtype of the new object as an attribute of the original object. If we want to have a different data type for the new object, we can do so by setting the dtype attribute of the function.
Syntax: Index.copy (name = None, deep = False, dtype = None, ** kwargs)
name: string, optional
deep : boolean, default False
dtype: numpy dtype or pandas type
Returns: copy: Index
Note: in most cases there should be no functional difference from using deep, but if deep is passed it will try to deep copy.
Example # 1: Use
Index.copy () to copy the Index value into a new object and change the data type of the new object to int64.
Let`s create a copy of an int64 object.
As we see in the output, the function returned a copy of the original index with the int64 type.
Example # 2: Use
Index.copy () to make a copy of the original object. Also set the name attribute of the new object and convert the string d to datetime.
Let`s make a copy of the original object.
| tr> |
As we can see in the output, the new object has data in datatime format, and its name attribute has also been set.
The role of adaptation, learning and optimization are becoming increasingly essen- tial and intertwined. The capability of a system to adapt either through modification of its physiological structure ...
Acquire and analyze data from all corners of the social web with Python. This book is for intermediate Python developers who want to engage with the use of public APIs to collect data from social m...
Automate the Boring Stuff with Python PDF, 2nd Edition: Practical Programming for Total Beginners Illustrated Edition. The second edition of this Python bestseller (over 100,000 copies sold in prin...
Spark is one of the hottest technologies in big data analysis right now, and with good reason. If you work for, or you hope to work for, a company that has massive amounts of data to analyze, Spark of...