Pandas Series: Difference between revisions
Line 45: | Line 45: | ||
==Create a Series from JSON== | ==Create a Series from JSON== | ||
<font color='darkkhaki'>Parse: https://pandas.pydata.org/docs/reference/api/pandas.read_json.html#pandas.read_json</font> | <font color='darkkhaki'>Parse: https://pandas.pydata.org/docs/reference/api/pandas.read_json.html#pandas.read_json</font> | ||
Also see: {{Internal|Pandas_Concepts#Datetime|datetime}} | |||
=Accessing Elements of a Series= | =Accessing Elements of a Series= |
Revision as of 17:54, 8 October 2023
External
- https://pandas.pydata.org/docs/user_guide/dsintro.html#series
- https://pandas.pydata.org/docs/reference/api/pandas.Series.html#pandas.Series
- https://www.geeksforgeeks.org/python-pandas-series/
Internal
Overview
A series is a one-dimensional array of values, where each value has a label. The labels are referred to as "axis labels" and they are managed by the series's index. By default, in absence of any explicit specification, a series gets a monotonic integer range index, starting with 0 and with the step 1, allowing retrieving data with 0-based integer indexes (see Accessing Elements of a Series below).
Data stored in series can be
Index
RangeIndex
RangeIndex(start=0, stop=3, step=1)
Time Series Index
A time series is a series whose index has datetime objects. To create a time series, ensure that the method that creates the series performs the conversion automatically, as show in the Create a Time Series from CSV section.
Create a Series
A series can be created from an in-memory list:
import pandas as pd
a = ['a', 'b', 'c']
s = pd.Series(a)
A series can also be created from data stored externally.
Create a Series from CSV
https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html#pandas.read_csv
To create a series from a CSV file:
import pandas as pd
# TODO
Create a Time Series from CSV
Create a Series from JSON
Parse: https://pandas.pydata.org/docs/reference/api/pandas.read_json.html#pandas.read_json
Also see:
Accessing Elements of a Series
This is known as indexing or subset selection.
Operations on Series
Filtering
Transformation
This class of operations are referred to as transformations or conversions.