Pandas DataFrame is a two-dimensional, size-mutable, tabular data which may contain labeled rows and columns. DataFrame is useful for tabular data manipulation. The class syntax includes four parameters that are the data, index, columns, data type and copy options.
DataFrame(data=None, index=None, columns=None, dtype=None, copy=False)
DataFrame Object Declaration
An example of a DataFrame declaration:
import pandas as pd
# prepare df parameters
data = [['A1', 'B1', 'C1'],
['A2', 'B2', 'C2'],
['A3', 'B3', 'C3']]
columns = ['A', 'B', 'C']
index = [1, 2, 3]
# declare df
df = pd.DataFrame(data, index, columns)
The outcome of the DataFrame declaration above is as follows:
DataFrame object loads data from CSV file
# load the remote data into a Pandas DataFrame
import pandas as pd
df = pd.read_csv('https://archive.org/download/crowdflower/text_emotion.csv', on_bad_lines='skip', encoding='latin-1')
DataFrame object saves data as a CSV file
df.to_csv('text_emotion.csv', index = False)