pandas.pydata.org/docs/user_guide/10min.html
4 Users
0 Comments
48 Highlights
1 Notes
Tags
Top Highlights
Creating a Series by passing a list of values, letting pandas create a default integer index:
Creating a DataFrame by passing a NumPy array, with a datetime index using date_range() and labeled columns:
Creating a DataFrame by passing a dictionary of objects that can be converted into a series-like structure:
df.sort_values(by="B")
s, DataFrame.at(), DataFrame.iat()
Selecting a single column, which yields a Series,
Selecting on a multi-axis by label: >>> In [27]: df.loc[:, ["A", "B"]]
By lists of integer position locations, similar to the NumPy/Python style: >>> In [34]: df.iloc[[1, 2, 4], [0, 2]]
df2[df2["E"].isin(["two", "four"])]
Using the isin() method for filtering:
df.at[dates[0], "A"] = 0
df2[df2 > 0] = -df2
A where operation with setting:
Reindexing allows you to change/add/delete the index on a specified axis. This returns a copy of the data:
f1 = df.reindex(index=dates[0:4], columns=list(df.columns) + ["E"])
).shift(2)
df.sub(s, axis="index")
s.value_counts()
# break it into pieces In [75]: pieces = [df[:3], df[3:7], df[7:]] In [76]: pd.concat(pieces) Out[76]:
df.groupby("A")[["C", "D"]].sum()
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.