Welcome to Foundation of Data Science Laboratory
Welcome to Foundation of Data Science Laboratory
2. Use Python to import the CSV file into a DataFrame.
import pandas as pd
# Load the LIAR dataset CSV file into a DataFrame
df = pd.read_csv('liar_dataset.csv')
# Display the first 5 rows of the DataFrame
print(df.head()) # By default it displays 5 rows
# Display the first two rows of the DataFrame
df.head(2)
When you run the code above, assuming your liar_dataset.csv file is correctly loaded, the output will display the first 5 rows of the DataFrame. The output will look something like this:
ID label statement \
0 1 barely-true Says the Annies List political group supports...
1 2 false When did the decline of coal start? It started...
2 3 false Hillary Clinton admits she wants to take your ...
3 4 false Health insurance premiums have doubled in Wis...
4 5 barely-true Democrats and Republicans in the House were ab...
subject speaker job_title state \
0 abortion Dwayne Bohac State Representative Texas
1 energy David Dewhurst Former Lt. Governor Texas
2 gun-control Alex Jones Radio host Texas
3 health-care Scott Walker Governor Wisconsin
4 government-efficiency James White State Representative Texas
party context
0 Republican campaign-ad
1 Republican speech
2 Republican radio-interview
3 Republican speech
4 Republican press-release
df = pd.read_csv('liar_dataset.csv'): This line reads the CSV file into a Pandas DataFrame.
df.head(): This function displays the first 5 rows of the DataFrame by default.
Replace 'liar_dataset.csv' with the actual path to your dataset file if it’s located elsewhere.