Are Rows and Columns treated essentially the same as a data object? For example, in the following:
import pandas as pd
df = pd.DataFrame([
{"Title": "Titanic", "ReleaseYear": 1997, "Director": "James Cameron"},
{"Title": "Spider-Man", "ReleaseYear": 2002, "Director": "Sam Raimi"}
]
title_column = df['Title']
print(title_column)
print (type(title_column))
row_one = df.loc[0]
print(row_one)
print (type(row_one))
They both return a Series
, where the Column is 0-indexed and the Row is Column-indexed:
0 Titanic
1 Spider-Man
Name: Title, dtype: object
<class 'pandas.core.series.Series'>
Title Titanic
ReleaseYear 1997
Director James Cameron
Name: 0, dtype: object
<class 'pandas.core.series.Series'>
And then, as soon as more than one column or row is selected, it becomes a DataFrame
. Are the Row and Column basically the same type of object, or what are the differences between them, in how they're used?