10 Minutes To Pandas
Có thể bạn quan tâm
Object creation#
See the Intro to data structures section.
Creating a Series by passing a list of values, letting pandas create a default RangeIndex.
In [3]: s = pd.Series([1, 3, 5, np.nan, 6, 8]) In [4]: s Out[4]: 0 1.0 1 3.0 2 5.0 3 NaN 4 6.0 5 8.0 dtype: float64Creating a DataFrame by passing a NumPy array with a datetime index using date_range() and labeled columns:
In [5]: dates = pd.date_range("20130101", periods=6) In [6]: dates Out[6]: DatetimeIndex(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-06'], dtype='datetime64[us]', freq='D') In [7]: df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list("ABCD")) In [8]: df Out[8]: A B C D 2013-01-01 0.469112 -0.282863 -1.509059 -1.135632 2013-01-02 1.212112 -0.173215 0.119209 -1.044236 2013-01-03 -0.861849 -2.104569 -0.494929 1.071804 2013-01-04 0.721555 -0.706771 -1.039575 0.271860 2013-01-05 -0.424972 0.567020 0.276232 -1.087401 2013-01-06 -0.673690 0.113648 -1.478427 0.524988Creating a DataFrame by passing a dictionary of objects where the keys are the column labels and the values are the column values.
In [9]: df2 = pd.DataFrame( ...: { ...: "A": 1.0, ...: "B": pd.Timestamp("20130102"), ...: "C": pd.Series(1, index=list(range(4)), dtype="float32"), ...: "D": np.array([3] * 4, dtype="int32"), ...: "E": pd.Categorical(["test", "train", "test", "train"]), ...: "F": "foo", ...: } ...: ) ...: In [10]: df2 Out[10]: A B C D E F 0 1.0 2013-01-02 1.0 3 test foo 1 1.0 2013-01-02 1.0 3 train foo 2 1.0 2013-01-02 1.0 3 test foo 3 1.0 2013-01-02 1.0 3 train fooThe columns of the resulting DataFrame have different dtypes:
In [11]: df2.dtypes Out[11]: A float64 B datetime64[us] C float32 D int32 E category F str dtype: objectIf you’re using IPython, tab completion for column names (as well as public attributes) is automatically enabled. Here’s a subset of the attributes that will be completed:
In [12]: df2.<TAB> # noqa: E225, E999 df2.A df2.bool df2.abs df2.boxplot df2.add df2.C df2.add_prefix df2.clip df2.add_suffix df2.columns df2.align df2.copy df2.all df2.count df2.any df2.combine df2.append df2.D df2.apply df2.describe df2.B df2.duplicated df2.diffAs you can see, the columns A, B, C, and D are automatically tab completed. E and F are there as well; the rest of the attributes have been truncated for brevity.
Từ khóa » H+hpp 4-0 50
-
H Or *.hpp For Your Class Definitions - C++ - Stack Overflow
-
Tailwind CSS - Rapidly Build Modern Websites Without Ever Leaving ...
-
Primer3 Input (version 0.4.0)
-
HPP-1 / HPP-2 15 PC | Druckregelventile | Müller Co-ax Gmbh
-
Advanced Video Coding - Wikipedia
-
NumPy Quickstart — NumPy V1.v0 Manual
-
Liverpool Thrash Newcastle 4-0 To Extend Lead At Top | Reuters
-
Champions Palmeiras Start Serie A Season With 4-0 Win | Reuters
-
GitHub: Where The World Builds Software · GitHub
-
Mathematics Stack Exchange