Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas print first column

df = pd.DataFrame({"Letters": ["a", "b", "c"], "Numbers": [1, 2, 3]})
first_column = df.iloc[:, 0]
Comment

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 install pygame in python 3.8 
Python :: find all nan columns pandas 
Python :: opencv draw two images side by side 
Python :: np array n same values 
Python :: is machine learning hard 
Python :: pandas group by month 
Python :: pyspark filter not null 
Python :: how to make a python exe 
Python :: panda select rows where column value inferior to 
Python :: filter dataframe with list 
Python :: pretty print list python 
Python :: python infinite value 
Python :: matplotlib add space between subplots 
Python :: how to get pc name with python 
Python :: how to get input in tkinter 
Python :: write dataframe to csv python 
Python :: first position dict python 
Python :: code for showing contents of a file and printing it in python 
Python :: timedelta year python 
Python :: read txt file pandas 
Python :: install wxpython 
Python :: py sleep function 
Python :: pip install torch error 
Python :: how to change column type to string in pandas 
Python :: pandas dataframe convert nan to string 
Python :: python print code 
Python :: dictionary from two columns pandas 
Python :: pandas datetime now 
Python :: matplotlib legend out of plot 
Python :: python get index of item in 2d list 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =