20190407-Time series in Pandas

1. 去除字符串中的空格:strip()

2. 调用dataframe中的所有column:df.columns

3. 字符串是否包含某个关键字:str.contains()

4. resample时间序列数据by day并且求和,此处利用pandas中True为1、False为0:resample('D').sum()

5. reindex()

6. np.abs(): 绝对值

7. mask:

8.pd.to_datetime用法之一:合并行数据生成datetime series.

还可以用来将文字格式转化为datetime格式。

9.dt.tz_localize()\dt.tz_convert()为现有时间数据设置时区并且转换时区

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 可以使用 `help()` 函数或者 `?` 符号来查看 Pandas Series 的参数。 1. 使用 `help()` 函数: ```python import pandas as pd # 创建一个 Pandas Series s = pd.Series([1, 2, 3]) # 使用 help() 函数查看 Series 的参数 help(pd.Series) ``` 运行结果: ``` Help on class Series in module pandas.core.series: class Series(pandas.core.generic.NDFrame) | Series(data=None, index=None, dtype=None, name=None, copy=False, fastpath=False) | | One-dimensional ndarray with axis labels (including time series). | | Labels need not be unique but must be a hashable type. The object supports | both integer- and label-based indexing and provides a host of methods for | performing operations involving the index. Statistical methods from | ndarray have been overridden to automatically exclude missing data (currently | represented as NaN) | | Method resolution order: | Series | pandas.core.generic.NDFrame | pandas.core.base.PandasObject | pandas.core.accessor.DirNamesMixin | pandas.core.base.StringMixin | builtins.object | | Methods defined here: | | __array__(self, dtype=None) -> numpy.ndarray | Return an array representing the values in the Series. | | .. versionadded:: 0.24.0 | | __bytes__(self) -> bytes | Return bytes representation of the Series. | | .. versionadded:: 0.24.0 | | __constructor__(self, *args, **kwargs) -> 'Series' | Constructor used when subclassing NDFrame. | | __init__(self, data=None, index=None, dtype=None, name=None, copy=False, fastpath=False) | One-dimensional ndarray with axis labels (including time series). | | Labels need not be unique but must be a hashable type. The object supports | both integer- and label-based indexing and provides a host of methods for | performing operations involving the index. Statistical methods from | ndarray have been overridden to automatically exclude missing data (currently | represented as NaN). | | Parameters | ---------- ... ``` 可以看到,打印出了 Series 的构造函数以及其它方法和属性的说明。 2. 使用 `?` 符号: ```python import pandas as pd # 创建一个 Pandas Series s = pd.Series([1, 2, 3]) # 使用 ? 符号查看 Series 的参数 s? ``` 运行结果: ``` Type: pandas.core.series.Series String form: 0 1 1 2 2 3 dtype: int64 Length: 3 Docstring: One-dimensional ndarray with axis labels (including time series). Labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index. Statistical methods from ndarray have been overridden to automatically exclude missing data (currently represented as NaN). ``` 可以看到,打印出了 Series 的数据类型、字符串形式、长度和文档字符串。 ### 回答2: 要查看Pandas Series的参数,可以使用`.describe()`和`.info()`这两个函数。 `.describe()`函数提供了有关Series的统计描述信息,包括计数、均值、标准差、最小值、25%分位数、中位数、75%分位数和最大值。这些统计数据可以帮助我们了解Series的基本特征。 另一个函数`.info()`提供了有关Series的基本信息,包括索引类型、数据类型和非空值的数量。这个函数还可以告诉你Series占用的内存空间。 例如,假设我们有一个名为`my_series`的Series,我们可以使用以下方式检查其参数: ```python import pandas as pd # 创建一个Series my_series = pd.Series([10, 20, 30, 40, 50]) # 使用.describe()函数查看参数 print(my_series.describe()) # 使用.info()函数查看参数 my_series.info() ``` 运行上述代码,我们会得到以下输出: ``` count 5.0 mean 30.0 std 15.8 min 10.0 25% 20.0 50% 30.0 75% 40.0 max 50.0 dtype: float64 <class 'pandas.core.series.Series'> RangeIndex: 5 entries, 0 to 4 Data columns (total 1 columns): 0 5 non-null int64 dtypes: int64(1) memory usage: 168.0 bytes ``` 从输出结果可以看出,Series中包含5个非空值,所有值的均值为30.0,标准差为15.8。此外,数据类型为int64,占用的内存空间为168.0字节。 ### 回答3: 要查看Pandas Series的参数,可以使用Python中的内置函数type()和dir()。首先,使用type()函数检查Series的类型。例如,假设我们有一个名为s的Series对象,可以使用type(s)来查看其类型。结果可能会显示"Serie"或类似的输出,以确认对象为Series类型。 接下来,使用dir()函数来查看Series对象的所有可用属性和方法。例如,可以使用dir(s)来查看Series对象s的所有属性和方法。该函数将返回一个包含对象所有属性和方法名称的列表。 另外,可以使用help()函数来获取关于Series对象的详细说明。例如,输入help(s)将会输出一个包含Series对象的详细文档字符串的帮助页面。 除了这些方法,还可以在Pandas官方文档中查找Series的参数和方法说明。Pandas官方文档提供了全面的文档,其中包含了Pandas库中的所有对象和功能的详细说明,包括Series对象的参数和方法。可以在网上搜索"Pandas官方文档"并浏览相关页面来查找有关Series对象的参数信息。 综上所述,要查找Pandas Series对象的参数,可以使用type()函数确认其类型,使用dir()函数查看其所有属性和方法,使用help()函数获取详细的说明,或者查看Pandas官方文档获取更全面的参数信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值