Pandas Concepts: Difference between revisions
Line 33: | Line 33: | ||
Date format when represented as string: <code>YYYY-MM-DD</code>, "2023-10-01". | Date format when represented as string: <code>YYYY-MM-DD</code>, "2023-10-01". | ||
==<tt>Timestamp</tt>== | ==<tt>Timestamp</tt>== | ||
Pandas has a replacement for Python <code>datetime.datetime</code> object, and that is <code>pandas.Timestamp</code>: {{External|https://pandas.pydata.org/docs/reference/api/pandas.Timestamp.html#pandas.Timestamp}} | Pandas has a replacement for Python <code>[[Time,_Date,_Timestamp_in_Python#The_datetime.datetime_Type|datetime.datetime]]</code> object, and that is <code>pandas.Timestamp</code>: {{External|https://pandas.pydata.org/docs/reference/api/pandas.Timestamp.html#pandas.Timestamp}} | ||
Also see {{Internal|Pandas_Series#Create_a_Time_Series_from_CSV|Create a Time Series from CSV}} | Also see {{Internal|Pandas_Series#Create_a_Time_Series_from_CSV|Create a Time Series from CSV}} | ||
Revision as of 03:36, 18 October 2023
External
Internal
Overview
pandas
is a Python package that provides fast, flexible, and expressive data structures designed to make working with "relational" or "labeled" data both easy and intuitive. It aims to be the fundamental high-level building block for doing practical, real world data analysis in Python. Pandas is built in top of Numpy. Pandas provides two main data structures DataFrame and Series, which share concepts like axis and index.
Axis
Both DataFrames and Series use the concept of axis. An axis means the direction in a bidimensional data matrix or a vector along which the means are computed. A DataFrame has a row axis and a column axis, while a Series has only one axis. The term comes from numpy, whose ndarray is used to implement the Panda Series. The indexes corresponding to a DataFrame or a Series axes are returned by the axes
property.
Index
An index is an immutable sequence used to address data stored in a DataFrame or a Series, and it can be thought of as individual elements labels, for a Series or as the row labels for a DataFrame. By default, it consists in 0-based monotonically increasing integers (RangeIndex
), but it can also consists in string labels, or in case of time series, by datetime instances (DatetimeIndex
). Other indexes: CategoricalIndex
, MultiIndex
, IntervalIndex
, TimedeltaIndex
, PeriodIndex
.
DataFrame and Series data elements can be addressed via both integral zero-based location, using the iloc[]
syntax, and also via index values, using the loc[]
syntax.
For details related to DataFrame and Series indexes, see:
DataFrame
Series
Time Series Processing with Pandas
Data Types
String
Datetime
Date format when represented as string: YYYY-MM-DD
, "2023-10-01".
Timestamp
Pandas has a replacement for Python datetime.datetime
object, and that is pandas.Timestamp
:
Also see
Visualization
Both the DataFrame and Series have a plot()
method, which delegates to matplotlib.
Datareader
pip3 install pandas_datareader