创建一个时间序列

pd.date_range()

这个函数是手动设置时间的范围,参数periods是设置时间间隔的

  1. # Create the range of dates here
  2. seven_days = pd.date_range('2017-1-1', periods=7)
  3. # Iterate over the dates and print the number and name of the weekday
  4. for day in seven_days:
  5. print(day.dayofweek, day.weekday_name)
  6. <script.py> output:
  7. 6 Sunday
  8. 0 Monday
  9. 1 Tuesday
  10. 2 Wednesday
  11. 3 Thursday
  12. 4 Friday
  13. 5 Saturday

info()

查看数据索引和内存信息的

  1. data = pd.read_csv('nyc.csv')
  2. # Inspect data
  3. print(data.info())
  4. # Convert the date column to datetime64
  5. data.date = pd.to_datetime(data.date)
  6. # Set date column as index
  7. data.set_index('date', inplace=True)
  8. # Inspect data
  9. print(data.info())
  10. # Plot data
  11. data.plot(subplots=True)
  12. plt.show()
  13. <script.py> output:
  14. <class 'pandas.core.frame.DataFrame'>
  15. RangeIndex: 6317 entries, 0 to 6316
  16. Data columns (total 4 columns):
  17. date 6317 non-null object
  18. ozone 6317 non-null float64
  19. pm25 6317 non-null float64
  20. co 6317 non-null float64
  21. dtypes: float64(3), object(1)
  22. memory usage: 197.5+ KB
  23. None
  24. <class 'pandas.core.frame.DataFrame'>
  25. DatetimeIndex: 6317 entries, 1999-07-01 to 2017-03-31
  26. Data columns (total 3 columns):
  27. ozone 6317 non-null float64
  28. pm25 6317 non-null float64
  29. co 6317 non-null float64
  30. dtypes: float64(3)
  31. memory usage: 197.4 KB
  32. None

  1. # Create dataframe prices here
  2. prices = pd.DataFrame()
  3. # Select data for each year and concatenate with prices here
  4. for year in ['2013', '2014', '2015']:
  5. price_per_year = yahoo.loc[year, ['price']].reset_index(drop=True)
  6. price_per_year.rename(columns={'price': year}, inplace=True)
  7. prices = pd.concat([prices, price_per_year], axis=1)
  8. # Plot prices
  9. prices.plot()
  10. plt.show()

asfred()

给已经存在的时间序列调整时间间隔

  1. # Inspect data
  2. print(co.info())
  3. # Set the frequency to calendar daily
  4. co = co.asfreq('D')
  5. # Plot the data
  6. co.plot(subplots=True)
  7. plt.show()
  8. # Set frequency to monthly
  9. co = co.asfreq('M')
  10. # Plot the data
  11. co.plot(subplots=True)
  12. plt.show()

shifted(),滞后函数

等价于r里面的lag()

peroid参数指定滞后阶数

\(x_t\)/\(x_{t-1}\)

diff()求差分

\(x_t\)-\(x_{t-1}\)

  1. # Import data here
  2. google = pd.read_csv('google.csv', parse_dates=['Date'], index_col='Date')
  3. # Set data frequency to business daily
  4. google = google.asfreq('B')
  5. # Create 'lagged' and 'shifted'
  6. google['lagged'] = google.Close.shift(periods=-90)
  7. google['shifted'] = google.Close.shift(periods=90)
  8. # Plot the google price series
  9. google.plot()
  10. plt.show()

加减乘除

  • 减:.sub()
  • 加:.add()
  • 成:.mul()
  • 除:.sub()

    这几个方法只能被数据框直接调用,不然会报错,这里可以补一下基础

    主要是因为这几个函数都是基于pandas的,而pandas这个包的操作就和tidyverse一样都是在数据框的基础上进行操作的

  1. # Convert index series to dataframe here
  2. data = index.to_frame('Index')
  3. # Normalize djia series and add as new column to data
  4. djia = djia.div(djia.iloc[0]).mul(100)
  5. data['DJIA'] = djia
  6. # Show total return for both index and djia
  7. print(data.iloc[-1].div(data.iloc[0]).sub(1).mul(100))
  1. # Create daily_return
  2. google['daily_return'] = google.Close.pct_change().mul(100)
  3. # Create monthly_return
  4. google['monthly_return'] = google.Close.pct_change(30).mul(100)
  5. # Create annual_return
  6. google['annual_return'] = google.Close.pct_change(360).mul(100)
  7. # Plot the result
  8. google['daily_return']
  9. google.plot(subplots=True)
  10. plt.show()



上面这几行的代码暴露一个问题是我的语法还是不太熟。。。

整熟了再往下学啊

  1. # Import data here
  2. prices = pd.read_csv('asset_classes.csv',parse_dates=['DATE'],index_col='DATE')
  3. # Inspect prices here
  4. print(prices.info())
  5. # Select first prices
  6. first_prices = prices.iloc[0]
  7. # Create normalized
  8. normalized = prices.div(first_prices).mul(100)
  9. # Plot normalized
  10. #画图这个地方老是写错,记住直接调用
  11. normalized.plot()
  12. plt.show()

  1. # Create tickers
  2. tickers = ['MSFT', 'AAPL']
  3. # Import stock data here
  4. stocks = pd.read_csv('msft_aapl.csv', parse_dates=['date'], index_col='date')
  5. # Import index here
  6. sp500 = pd.read_csv('sp500.csv', parse_dates=['date'], index_col='date')
  7. # Concatenate stocks and index here
  8. data = pd.concat([stocks, sp500], axis=1).dropna()
  9. # Normalize data
  10. normalized = data.div(data.iloc[0]).mul(100)
  11. # Subtract the normalized index from the normalized stock prices, and plot the result
  12. normalized[tickers].sub(normalized['SP500'], axis=0).plot()
  13. plt.show()

DataFrame.reindex()

这个函数就是重新定义索引

DataFrame.reindex(self, labels=None, index=None, columns=None, axis=None, method=None, copy=True, level=None, fill_value=nan, limit=None, tolerance=None)[source]

通过data_range指定时间序列的起止时间

  1. # Set start and end dates
  2. start = '2016-1-1'
  3. end = '2016-2-29'
  4. # Create monthly_dates here
  5. #这个就是创建一个指定的起止时间,然后有相同的时间间隔
  6. monthly_dates = pd.date_range(start=start, end=end, freq='M')
  7. # Create monthly here,构造一个时间序列,但是要给一个时间戳
  8. monthly = pd.Series(data=[1,2], index=monthly_dates)
  9. print(monthly)
  10. # Create weekly_dates here
  11. weekly_dates = pd.date_range(start=start, end=end, freq='W')
  12. # Print monthly, reindexed using weekly_dates
  13. print(monthly.reindex(weekly_dates))
  14. print(monthly.reindex(weekly_dates, method='bfill'))
  15. print(monthly.reindex(weekly_dates, method='ffill'))
  16. #ffill : foreaward fill 向前填充,
  17. #如果新增加索引的值不存在,那么按照前一个非nan的值填充进去
  18. 同理,bfill是后向补充
  19. <script.py> output:
  20. 2016-01-31 1
  21. 2016-02-29 2
  22. Freq: M, dtype: int64
  23. 2016-01-03 NaN
  24. 2016-01-10 NaN
  25. 2016-01-17 NaN
  26. 2016-01-24 NaN
  27. 2016-01-31 1.0
  28. 2016-02-07 NaN
  29. 2016-02-14 NaN
  30. 2016-02-21 NaN
  31. 2016-02-28 NaN
  32. Freq: W-SUN, dtype: float64
  33. 2016-01-03 1
  34. 2016-01-10 1
  35. 2016-01-17 1
  36. 2016-01-24 1
  37. 2016-01-31 1
  38. 2016-02-07 2
  39. 2016-02-14 2
  40. 2016-02-21 2
  41. 2016-02-28 2
  42. Freq: W-SUN, dtype: int64
  43. 2016-01-03 NaN
  44. 2016-01-10 NaN
  45. 2016-01-17 NaN
  46. 2016-01-24 NaN
  47. 2016-01-31 1.0
  48. 2016-02-07 1.0
  49. 2016-02-14 1.0
  50. 2016-02-21 1.0
  51. 2016-02-28 1.0
  52. Freq: W-SUN, dtype: float64

通过as.fred()指定时间序列的间隔

这个比较适合读入是时间序列的数据,然后直接做处理

  1. # Import data here
  2. data = pd.read_csv('unemployment.csv', parse_dates=['date'], index_col='date')
  3. # Show first five rows of weekly series
  4. print(data.asfreq('W').head())
  5. # Show first five rows of weekly series with bfill option
  6. print(data.asfreq('W', method='bfill').head())
  7. # Create weekly series with ffill option and show first five rows
  8. weekly_ffill = data.asfreq('W', method='ffill')
  9. print(weekly_ffill.head())
  10. # Plot weekly_fill starting 2015 here
  11. weekly_ffill.loc['2015':].plot()
  12. plt.show()

interpolate()

这个函数是根据需求进行插值,目前的理解就是因为存在很多的缺失值进行插补,达到剔除缺失值的目的,一般情况下会暴力删除缺失值,剔除行或者列

官方文档有个demo

  1. >>> s = pd.Series([np.nan, "single_one", np.nan,
  2. ... "fill_two_more", np.nan, np.nan, np.nan,
  3. ... 4.71, np.nan])
  4. >>> s
  5. 0 NaN
  6. 1 single_one
  7. 2 NaN
  8. 3 fill_two_more
  9. 4 NaN
  10. 5 NaN
  11. 6 NaN
  12. 7 4.71
  13. 8 NaN
  14. dtype: object
  15. >>> s.interpolate(method='pad', limit=2)
  16. 0 NaN
  17. 1 single_one
  18. 2 single_one
  19. 3 fill_two_more
  20. 4 fill_two_more
  21. 5 fill_two_more
  22. 6 NaN
  23. 7 4.71
  24. 8 4.71
  25. dtype: object

resample()

这个函数可以给已经存在的时间序列重新划分frequency

DataFrame.resample(self, rule, how=None, axis=0, fill_method=None, closed=None, label=None, convention='start', kind=None, loffset=None, limit=None, base=0, on=None, level=None)

  1. # Import and inspect data here
  2. ozone = pd.read_csv('ozone.csv',parse_dates=['date'],index_col='date')
  3. print(ozone.info())
  4. # Calculate and plot the weekly average ozone trend
  5. #日期的fre是week,并且求出每周的平均值
  6. ozone.resample('W').mean().plot()
  7. plt.show()

补充一个绘图的参数

plot(subplots=True)

这个参数代表的是有子图,且子图共用y轴

first()

这个函数是打印指定的前几行,但是不包括end

  1. >>> i = pd.date_range('2018-04-09', periods=4, freq='2D')
  2. >>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
  3. >>> ts
  4. A
  5. 2018-04-09 1
  6. 2018-04-11 2
  7. 2018-04-13 3
  8. 2018-04-15 4
  9. Get the rows for the first 3 days:
  10. >>> ts.first('3D')
  11. A
  12. 2018-04-09 1
  13. 2018-04-11 2

pct_change()

DataFrame.pct_change(periods=1, fill_method=‘pad’, limit=None, freq=None, **kwargs)

表示当前元素与先前元素的相差百分比,当然指定periods=n,表示当前元素与先前n 个元素的相差百分比

嗯,这个函数适合批量求百分比

官方文档给的例子或许更好理解

  1. >>> df = pd.DataFrame({
  2. ... 'FR': [4.0405, 4.0963, 4.3149],
  3. ... 'GR': [1.7246, 1.7482, 1.8519],
  4. ... 'IT': [804.74, 810.01, 860.13]},
  5. ... index=['1980-01-01', '1980-02-01', '1980-03-01'])
  6. >>> df
  7. FR GR IT
  8. 1980-01-01 4.0405 1.7246 804.74
  9. 1980-02-01 4.0963 1.7482 810.01
  10. 1980-03-01 4.3149 1.8519 860.13
  11. >>> df.pct_change()
  12. FR GR IT
  13. 1980-01-01 NaN NaN NaN
  14. 1980-02-01 0.013810 0.013684 0.006549
  15. 1980-03-01 0.053365 0.059318 0.061876

pd.contact()

这个函数应该是类似于R 里面的rbind按行拼接,即纵向合并

  1. >>> pd.concat([s1, s2], ignore_index=True)
  2. 0 a
  3. 1 b
  4. 2 c
  5. 3 d
  6. dtype: object

agg()

与groupby对应的聚合函数,有点类似于summarize

将一些基础运算整合到一起

rolling window functions.

滚动窗口函数

不知道之前的garch模型滑动窗口是不是用到了这个,这个我再查一下,确实不太明白

查到了 参考

“时点的数据波动较大,某一点的数据不能很好的表现它本身的特性,于是我们就想,能否用一个区间的的数据去表现呢,这样数据的准确性是不是更好一些呢?因此,引出滑动窗口(移动窗口)的概念,简单点说,为了提升数据的可靠性,将某个点的取值扩大到包含这个点的一段区间,用区间来进行判断,这个区间就是窗口。如下面的示意图所示,其中时间序列数据代表的是15日每日的温度,现在我们以3天为一个窗口,将这个窗口从左至右依次滑动,统计出3天的平均值作为这个点的值,比如3号的温度就是1号、2号、3号的平均温度”

DataFrame.rolling(window, min_periods=None, center=False, win_type=None, on=None, axis=0, closed=None)

  • window

    时间窗的大小,一般有两种形式,int:表示计算统计量的观测值的数量,即向前几个数量,要是offset则表示时间窗的大小。

    min_periods:每个窗口最少包含的观测值的数量,小于这个窗口就是na

rolling()

join()

合并数据表的一个函数

两个DataFrame中的不同的列索引合并成为一个DataFrame

  1. # Import and inspect ozone data here
  2. data = pd.read_csv('ozone.csv', parse_dates=['date'], index_col='date').dropna()
  3. # Calculate the rolling mean and std here
  4. rolling_stats = data.Ozone.rolling(360).agg(['mean', 'std'])
  5. # Join rolling_stats with ozone data
  6. #默认左拼接,有点像R里面的left_join()
  7. stats = data.join(rolling_stats)
  8. # Plot stats
  9. stats.plot(subplots=True);
  10. plt.show()

quantile()

分位数函数

四分位数

概念:把给定的乱序数值由小到大排列并分成四等份,处于三个分割点位置的数值就是四分位数。

第1四分位数 (Q1),又称“较小四分位数”,等于该样本中所有数值由小到大排列后第25%的数字。

第2四分位数 (Q2),又称“中位数”,等于该样本中所有数值由小到大排列后第50%的数字。

第3四分位数 (Q3),又称“较大四分位数”,等于该样本中所有数值由小到大排列后第75%的数字。

四分位距(InterQuartile Range, IQR)= 第3四分位数与第1四分位数的差距

同时拓展到多分位数的概念

  1. # Resample, interpolate and inspect ozone data here
  2. data = data.resample('D').interpolate()
  3. data.info()
  4. # Create the rolling window
  5. rolling = data.rolling(360)['Ozone']
  6. # Insert the rolling quantiles to the monthly returns
  7. data['q10'] = rolling.quantile(.1)
  8. data['q50'] = rolling.quantile(.5)
  9. data['q90'] = rolling.quantile(.9)
  10. # Plot the data
  11. data.plot()
  12. plt.show()

append()

向dataframe对象中添加新的行,如果添加的列名不在dataframe对象中,将会被当作新的列进行添加

这个函数挺好使的 参考下官方文档 demo很好理解

可以进行行列合并

pandas 中统计累计次数

.cumsum()

累加

.cumprod()

累乘

  1. # Import numpy
  2. import numpy as np
  3. # Define a multi_period_return function
  4. def multi_period_return(period_returns):
  5. return np.prod(period_returns + 1) - 1
  6. # Calculate daily returns
  7. daily_returns = data.pct_change()
  8. # Calculate rolling_annual_returns
  9. rolling_annual_returns = daily_returns.rolling('360D').apply(multi_period_return)
  10. # Plot rolling_annual_returns
  11. rolling_annual_returns.mul(100).plot();
  12. plt.show()

np.prod这个是numpy里面求阶乘的

  1. # Create multi_period_return function here
  2. def multi_period_return(r):
  3. return (np.prod(r + 1) - 1) * 100

定义一个函数然后直接调用就行,计算数组乘积

一个案例学习

seed()

设定种子简书

设定生成随机数的种子,种子是为了让结果具有重复性,重现结果。如果不设定种子,生成的随机数无法重现

计算机并不能产生真正的随机数,如果你不设种子,计算机会用系统时钟来作为种子,如果你要模拟什么的话,每次的随机数都是不一样的,这样就不方便你研究,如果你事先设置了种子,这样每次的随机数都是一样的,便于重现你的研究,也便于其他人检验你的分析结果

random walk

  1. # Set seed here
  2. seed(42)
  3. # Create random_walk
  4. random_walk = normal(loc=.001, scale=0.01, size=2500)
  5. # Convert random_walk to pd.series
  6. random_walk = pd.Series(random_walk)
  7. # Create random_prices
  8. random_prices = random_walk.add(1).cumprod()
  9. # Plot random_prices here
  10. random_prices.mul(1000).plot()
  11. plt.show();

choice()

随机抽样函数

生成随机数

Relationships between time series: correlation

heatmap()

相关系数矩阵热力图

之前论文中读到的热图,这回终于知道该怎么画了

  1. # Inspect data here
  2. print(data.info())
  3. # Calculate year-end prices here
  4. annual_prices = data.resample('A').last()
  5. # Calculate annual returns here
  6. annual_returns = annual_prices.pct_change()
  7. # Calculate and print the correlation matrix here
  8. correlations = annual_returns.corr()
  9. print(correlations)
  10. # Visualize the correlations as heatmap here
  11. sns.heatmap(correlations, annot=True)
  12. plt.show();

Select index components & import data

groupby()

简书

和R里面的group_by函数是一样的,好好用哦,之前写了一个for循环还是给写错了,真的是。。卧槽。。md

  1. # Select largest company for each sector
  2. components = listings.groupby(['Sector'])['Market Capitalization'].nlargest(1)
  3. # Print components, sorted by market cap
  4. print(components.sort_values(ascending=False))
  5. # Select stock symbols and print the result
  6. tickers = components.index.get_level_values('Stock Symbol')
  7. print(tickers)
  8. # Print company name, market cap, and last price for each component
  9. info_cols = ['Company Name', 'Market Capitalization', 'Last Sale']
  10. print(listings.loc[tickers, info_cols].sort_values('Market Capitalization', ascending=False))
  11. <script.py> output:
  12. Sector Stock Symbol
  13. Technology AAPL 740,024.47
  14. Consumer Services AMZN 422,138.53
  15. Miscellaneous MA 123,330.09
  16. Health Care AMGN 118,927.21
  17. Transportation UPS 90,180.89
  18. Finance GS 88,840.59
  19. Basic Industries RIO 70,431.48
  20. Public Utilities TEF 54,609.81
  21. Consumer Non-Durables EL 31,122.51
  22. Capital Goods ILMN 25,409.38
  23. Energy PAA 22,223.00
  24. Consumer Durables CPRT 13,620.92
  25. Name: Market Capitalization, dtype: float64
  26. Index(['RIO', 'ILMN', 'CPRT', 'EL', 'AMZN', 'PAA', 'GS', 'AMGN', 'MA', 'TEF', 'AAPL', 'UPS'], dtype='object', name='Stock Symbol')
  27. Company Name Market Capitalization Last Sale
  28. Stock Symbol
  29. AAPL Apple Inc. 740,024.47 141.05
  30. AMZN Amazon.com, Inc. 422,138.53 884.67
  31. MA Mastercard Incorporated 123,330.09 111.22
  32. AMGN Amgen Inc. 118,927.21 161.61
  33. UPS United Parcel Service, Inc. 90,180.89 103.74
  34. GS Goldman Sachs Group, Inc. (The) 88,840.59 223.32
  35. RIO Rio Tinto Plc 70,431.48 38.94
  36. TEF Telefonica SA 54,609.81 10.84
  37. EL Estee Lauder Companies, Inc. (The) 31,122.51 84.94
  38. ILMN Illumina, Inc. 25,409.38 173.68
  39. PAA Plains All American Pipeline, L.P. 22,223.00 30.72
  40. CPRT Copart, Inc. 13,620.92 29.65

最后一行or一列的表示方法

可以用“-1”表示

sort_values

这个函数就是排序函数,类似于r里面的arrange函数

plotz中的参数kind

这个参数是用来设置绘图类型的

  1. # Select the number of shares
  2. no_shares = components['Number of Shares']
  3. print(no_shares.sort_values())
  4. # Create the series of market cap per ticker
  5. market_cap = stock_prices.mul(no_shares)
  6. # Select first and last market cap here
  7. first_value = market_cap.iloc[0]
  8. last_value = market_cap.iloc[-1]
  9. # Concatenate and plot first and last market cap here
  10. pd.concat([first_value, last_value], axis=1).plot(kind='barh')
  11. plt.show()

to_excel()

将数据输出到excel中

  1. # Export data and data as returns to excel
  2. with pd.ExcelWriter('data.xls') as writer:
  3. data.to_excel(writer, sheet_name='data')
  4. returns.to_excel(writer, sheet_name='returns')

还行吧,记住语法,多尝试几遍就好了

pandas时间序列学习笔记的更多相关文章

  1. pandas包学习笔记

    目录 zip Importing & exporting data Plotting with pandas Visual exploratory data analysis 折线图 散点图 ...

  2. pandas库学习笔记(二)DataFrame入门学习

    Pandas基本介绍——DataFrame入门学习 前篇文章中,小生初步介绍pandas库中的Series结构的创建与运算,今天小生继续“死磕自己”为大家介绍pandas库的另一种最为常见的数据结构D ...

  3. 初步了解pandas(学习笔记)

    1 pandas简介 pandas 是一种列存数据分析 API.它是用于处理和分析输入数据的强大工具,很多机器学习框架都支持将 pandas 数据结构作为输入. 虽然全方位介绍 pandas API ...

  4. pandas库学习笔记(一)Series入门学习

    Pandas基本介绍: pandas is an open source, BSD-licensed (permissive free software licenses) library provi ...

  5. python的pandas库学习笔记

    导入: import pandas as pd from pandas import Series,DataFrame 1.两个主要数据结构:Series和DataFrame (1)Series是一种 ...

  6. Pandas DataFrame学习笔记

    对一个DF r1  r2  r3 c1 c2 c3 选行:  df['r1']  df['r2':'r2']  #包含r2  df[df['c1']>5] #按条件选 选列:  df['c1'] ...

  7. 数据分析之Pandas和Numpy学习笔记(持续更新)<1>

    pandas and numpy notebook        最近工作交接,整理电脑资料时看到了之前的基于Jupyter学习数据分析相关模块学习笔记.想着拿出来分享一下,可是Jupyter导出来h ...

  8. Pandas学习笔记

    本学习笔记来自于莫烦Python,原视频链接 一.Pandas基本介绍和使用 Series数据结构:索引在左,值在右 import pandas as pd import numpy as np s ...

  9. Pandas 学习笔记

    Pandas 学习笔记 pandas 由两部份组成,分别是 Series 和 DataFrame. Series 可以理解为"一维数组.列表.字典" DataFrame 可以理解为 ...

随机推荐

  1. 使用Java, AppleScript对晓黑板进行自动打卡

    使用Java, AppleScript对晓黑板进行自动打卡 由于我们学校要求每天7点起床打卡,但是实在做不到,遂写了这个脚本. 绪论 由于晓黑板不支持网页版,只能使用App进行打卡,所以我使用网易的安 ...

  2. chrome报错:您目前无法访问 因为此网站使用了 HSTS

    chrome报错:您目前无法访问 因为此网站使用了 HSTS 其然: 现象 :访问github仓库报错'您目前无法访问XXXX 因为此网站使用了 HSTS' 解决方法:清理HSTS的设定,重新获取.c ...

  3. vim 快捷键方式

    https://juejin.im/post/5ab1275d5188255588053e70#heading-14 安装方式 https://juejin.im/entry/57b281f72e95 ...

  4. android应用开发错误:Your project contains error(s),please fix them before running your

    重新打开ECLIPSE运行android项目,或者一段时间为运行ECLIPSE,打开后,发现新建项目都有红叉,以前的项目重新编译也有这问题,上网搜索按下面操作解决了问题 工程上有红叉,不知道少了什么, ...

  5. StarUML之六、StarUML规则与快捷键

    本章内容参考官网即可,不做详细说明,实践出真知! starUMl规则主要是在模型设计的约束条件 https://docs.staruml.io/user-guide/validation-rules ...

  6. ggEditor给节点增加提示框

    参考官方文档: https://www.yuque.com/antv/g6/plugin.tool.tooltip 在react-ggEditor使用方法: import React from 're ...

  7. shell 一键配置单实例oracle基础环境变量(linux7)

    #!/bin/bash echo "修改主机名" hostnamectl set-hostname wangxfa hostname sleep 1 echo "查看并关 ...

  8. P2024 NOI2001 种类冰茶鸡

    展开 题目描述 动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形.A 吃 B,B 吃 C,C 吃 A. 现有 N 个动物,以 1 - N 编号.每个动物都是 A,B,C 中的一种, ...

  9. 全网小说免费阅读下载APP

    先说主题:今天分享一个全网小说免费阅读下载APP.这篇文章是凌晨2点钟写的,原因呢可能有两点: 半夜无眠,一时兴起就想分享点有用的东西给大家,就问你感动不?其实吧,可能是晚上喝了点儿浓茶导致的无眠,所 ...

  10. Uva12169 扩展欧几里得模板

    Uva12169(扩展欧几里得) 题意: 已知 $x_i=(a*x_{i-1}+b) mod 10001$,且告诉你 $x_1,x_3.........x_{2t-1}$, 让你求出其偶数列 解法: ...