Skip to content

Instantly share code, notes, and snippets.

@itamarst
Last active March 21, 2018 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itamarst/bc05229920f9042405f310e99ad7fbe4 to your computer and use it in GitHub Desktop.
Save itamarst/bc05229920f9042405f310e99ad7fbe4 to your computer and use it in GitHub Desktop.
frames and series
In [4]: df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}, index=["x", "y", "z"])
In [5]: df
Out[5]:
a b
x 1 4
y 2 5
z 3 6
In [6]: df["a"]
Out[6]:
x 1
y 2
z 3
Name: a, dtype: int64
In [7]: df["a"].values
Out[7]: array([1, 2, 3])
In [10]: df["a"].loc["y"]
Out[10]: 2
In [12]: df["b"]
Out[12]:
x 4
y 5
z 6
Name: b, dtype: int64
In [13]: df["b"].loc["z"]
Out[13]: 6
In [14]: type(df["a"])
Out[14]: pandas.core.series.Series
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment