Skip to main content

Kang lib of Python package: calculate my math function

This project has been quarantined.

PyPI Admins need to review this project before it can be restored. While in quarantine, the project is not installable by clients, and cannot be being modified by its maintainers.

Read more in the project in quarantine help article.

Project description

welcome to Kang digital magic world: V0.3:calculate_weighted_value thank you for your trust. if you have any questions, please contact me. kangxiaowen@gmail.com

首先,创建两个DataFrame:一个是活动水平序列,另一个是权重序列。请看以下的Python代码:

import pandas as pd
import kanglib
import matplotlib.pyplot as plt

# 创建一个日期范围
dates = pd.date_range(start='2022-01-01', periods=365)

# 创建活动水平DataFrame
activity_levels_df = pd.DataFrame({
    'date': dates,
    'activity_level': [0.2] * len(dates)
})

# 创建权重DataFrame
weights_df = pd.DataFrame({
    'date': dates,
    'weight': [0.5] * len(dates)
})

# 合并这两个DataFrame
df = pd.merge(activity_levels_df, weights_df, on='date')

# 使用calculate_weighted_value函数
df = kanglib.calculate_weighted_value(df, ['activity_level'], 'weight', 'result')

# 打印DataFrame
print(df)

# 绘制结果
plt.plot(df['date'], df['result'])
plt.title('Weighted Activity Level over Time')
plt.xlabel('Date')
plt.ylabel('Weighted Activity Level')
plt.show()

这段代码首先创建了两个DataFrame,一个包含活动水平,另一个包含权重,都是针对相同的日期范围。然后,它们被合并到同一个DataFrame中,然后使用calculate_weighted_value函数计算加权活动水平。然后它打印出这个DataFrame,并将结果列绘制成一条折线图,x轴是日期,y轴是加权活动水平。


python setup.py sdist bdist_wheel

twine upload dist/*


使用示例

下面是如何使用 kanglib.calculate_weighted_value 函数的示例:

import pandas as pd
import kanglib
import matplotlib.pyplot as plt
import numpy as np

# 创建一个日期范围
dates = pd.date_range(start='2022-01-01', periods=365*2)

# 创建活动水平DataFrame
activity_levels_df = pd.DataFrame({
    'date': dates,
    'activity_level': np.random.rand(len(dates))
})

# 创建权重DataFrame
weights_df = pd.DataFrame({
    'date': dates,
    'weight': np.random.rand(len(dates))
})

# 合并这两个DataFrame
df = pd.merge(activity_levels_df, weights_df, on='date')

# 使用calculate_weighted_value函数
df = kanglib.calculate_weighted_value(df, ['activity_level'], 'weight', 'result')

# 打印DataFrame
print(df)

# 绘制结果
plt.plot(df['date'], df['result'])
plt.title('Weighted Activity Level over Time')
plt.xlabel('Date')
plt.ylabel('Weighted Activity Level')
plt.show()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kanglib-0.5.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kanglib-0.5-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file kanglib-0.5.tar.gz.

File metadata

  • Download URL: kanglib-0.5.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for kanglib-0.5.tar.gz
Algorithm Hash digest
SHA256 4954d982876892234e24816610889173fc1a66100630104e5336bce412cd75df
MD5 b6ef94aa5fb1f48f6af24a30ec7617d3
BLAKE2b-256 0774e23141921f22e1a3449edd05eef3b6b9c67b4e7e155c131db644e1957c18

See more details on using hashes here.

File details

Details for the file kanglib-0.5-py3-none-any.whl.

File metadata

  • Download URL: kanglib-0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for kanglib-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 225107ceb92fdb6704639d6c220038d276a017e0e24cdaed3e0671660994f385
MD5 642c82d347bb310acc3826a107ee2cd1
BLAKE2b-256 771a18bc1879c8081b1d90d7bfa95cbff6ca86a948df5ce7e07ab0b5490e0822

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page