Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

first column of a dataframe python

import pandas as pd
# List of Tuples
empoyees = [('Jack',    34, 'Sydney',   5) ,
            ('Riti',    31, 'Delhi' ,   7) ,
            ('Aadi',    16, 'London',   11) ,
            ('Mark',    41, 'Delhi' ,   12)]
# Create a DataFrame object
df = pd.DataFrame(  empoyees, 
                    columns=['Name', 'Age', 'City', 'Experience'])
print("Contents of the Dataframe : ")
print(df)
# Select first column of the dataframe as a dataframe object
first_column = df.iloc[: , :1]
print("First Column Of Dataframe: ")
print(first_column)
print("Type: " , type(first_column))
# Select first column of the dataframe as a series
first_column = df.iloc[:, 0]
print("First Column Of Dataframe: ")
print(first_column)
print("Type: " , type(first_column))
Comment

PREVIOUS NEXT
Code Example
Python :: how to get the local time in python 
Python :: System.Windows.Forms.DataGridView.CurrentRow.get returned null. c# 
Python :: python check if array is subset of another 
Python :: tensorflow bert implementation 
Python :: 1d array to one hot 
Python :: how to sort list of dictionaries in python 
Python :: clone website in python 
Python :: str to tuple of float 
Python :: discord.py get channel id by channel name 
Python :: is python platform independent 
Python :: 2d gaussian function python 
Python :: python float print 2 digits 
Python :: python send image server 
Python :: python recursively print directory 
Python :: remove item from list python 
Python :: django login code 
Python :: how to change size of turtle in python 
Python :: python read integer from stdin 
Python :: pandas data profiling 
Python :: scaling data 
Python :: urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997) 
Python :: drop na dataframe 
Python :: python challenges 
Python :: tensorflow adam 
Python :: python dataframe replace nan with 0 
Python :: on progress callback pytube 
Python :: Find the title of a page in python 
Python :: how to get the first key of a dictionary in python 
Python :: python string indexing 
Python :: pandas new column average of other columns 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =