A database with multiple data sets that support drawing, These data sets are: World population data set, World Carbon dioxide Concentration data set, World Number of Cities data set, China number of population data set, China number of space vehicles data set......
Project description
A database with multiple data sets that support drawing, These data sets are: World population data set, World Carbon dioxide Concentration data set, World Number of Cities data set, China number of population data set, China number of space vehicles data set......
- Function introduction
- download
- use
- Additional Features
- What data do we have
- Donation
- About Pypi
- license
Features
This project is a dataset with multiple functions, there are many datasets in it, and it has been uploaded to Pypi.
Download
This project uses Pypi, so it is recommended to use Pypi to download There are some dependent libraries, please paste the following code into the terminal
pip3 install simplejson
pip3 install openpyxl
pip3 install matplotlib
pip3 install setuptools
Code: pip3 install Wdatabase
Use
The package name when we upload is not the same as the package name used in actual use When importing, use the following code
from Wdata import WdataMain as main
The main class has the following functions:
| Functions | Introduction | Syntax | Return Type |
|---|---|---|---|
| draw | Draw | Func() | None |
| Save_file | Save file | Func(filename:str, type='json', Sheet='Data', RowOrColumn=True) | bool |
Import Data
Wdata has a lot of data sets, here we use 200 years of population growth data as an example
The syntax of Wdata_class is as follows:
WdataMain(json_fname: str)
json_fname is the name of the dataset
from Wdata import WdataMain as main
test = main('Population_growth') # import population growth over 200 years
Get data
We can use the dict() function to fetch the data
such as these codes
from Wdata import WdataMain as main
test = main('Population_growth') # import population growth over 200 years
print(dict(test))
after running
~/python test.py
{
'1800': 900000000,
'1820': 1100000000,
'1840': 1200000000,
'1860': 1300000000,
'1880': 1400000000,
'1900': 1650000000,
'1920': 1800000000,
'1940': 2200000000,
'1960': 3000000000,
'1980': 4400000000,
'2000': 5900000000,
'2022': 7400000000
}
Drawing
Drawing functions use the draw() function
as the following code
from Wdata import WdataMain as main
test = main('Population_growth') # import population growth over 200 years
test.draw()
The result is this
Data save
You can use the Save_file() function to save data
The syntax of Save_file is Save_file(filename:str, type=JSON, Sheet='Data',RowOrColumn=True) -> None
Parameter description:
The filename 'parameter is used to describe saving a file
The type 'parameter is used to describe the file type
Sheet only takes effect when saving a .xlsx file, representing a saved worksheet
RowOrColumn only takes effect when saving a .xlsx file, indicating the saved format
The file types are as follows:
| File Type | Usage | Description |
|---|---|---|
| Csv | Wdata.CSV | Save File file.csv |
| Json | Wdata.JSON | Save the file file. json as the default option |
| XLSX | Wdata.XLSX | Save File file.xlsx |
Such as the following code
from Wdata import WdataMain as main
test = main('Population_growth')
test. Save_file('Package_test') # Default option
Save the code for the CSV file
from Wdata import WdataMain as main
from Wdata import XLSX
test = main('Population_growth') # Population growth over the past 200 years
test. Save_file('Package_test', CSV) # The function automatically adds .csv suffix
Saving .xlsx files uses the Sheet and RowOrColumn parameters
Sheet means save cell, which defaults to Data
RowOrColumn means saved form, defaulting to True
from Wdata import WdataMain as main
from Wdata import XLSX
test = main('Population_growth') # Population growth over the past 200 years
test. Save_file('Package_test', XLSX) # This function automatically adds .xlsx suffix
# test. Save_file('Package_test', XLSX, RowOrColumn=False) This code is saved as a column
When RowOrColumn is True, the saved form looks like this
| 1820 | 1840 | 1860 | 1880 | 1900 | 1920 | 1940 | 1960 | 1980 | 2000 | 2022 |
|---|---|---|---|---|---|---|---|---|---|---|
| 1100000000 | 1200000000 | 1300000000 | 1400000000 | 1650000000 | 1800000000 | 2200000000 | 3000000000 | 4400000000 | 5900000000 | 7400000000 |
On the contrary, it is like this
| 1820 | 1100000000 |
|---|---|
| 1840 | 1200000000 |
| 1860 | 1300000000 |
| 1880 | 1400000000 |
| 1900 | 1650000000 |
| 1920 | 1800000000 |
| 1940 | 2200000000 |
| 1960 | 3000000000 |
| 1980 | 4400000000 |
| 2000 | 5900000000 |
| 2022 | 7400000000 |
Additional Features
Cosine similarity function
The cosine similarity function can calculate the cosine similarity of two coordinates in two-dimensional space according to the cosine similarity formula usage method:
from Wdata import mathfunc
Xy1=(2, 3) # First coordinate
Xy2=(3, 5) # Second coordinate
Result=mathfunc.similarity (xy1, xy2) # Cosine similarity
print(result)
Distance formula
Distance formula Use Euclid distance formula to calculate the distance between two coordinates in two-dimensional space usage method:
from Wdata import mathfunc
xy1 = (2, 3)
xy2 = (3, 5)
Result=mathfunc.distance (xy1, xy2) # Distance formula
print(result)
What data do we have
Currently we have the following data
| name | description | unit of measure |
|---|---|---|
| Population_growth | Population Growth 1800-2022 | People |
| Chinese_spacecraft | 2017-2020.06 Chinese spacecraft launches | Spacecraft |
| World_spacecraft | 2017-2020.06 World Spacecraft Launches | Spacecraft |
The above data comes from Bing and Baidu. The author cannot guarantee the accuracy of the data and should not be used for professional purposes
Donate
Due to special reasons, the author was unable to register a Paypal account and was forced to use Alipay
For details, please see Donation Instructions
About Pypi
The Wdataorg team has used twine to upload this library to Pypi
Wdatabase Pypi warehouse address
License
This open source project uses Apache License 2.0
In the process of using this open source project, please use it strictly in accordance with the license
The final interpretation right belongs to the development team Wdataorg
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Wdatabase-2.3.0.tar.gz.
File metadata
- Download URL: Wdatabase-2.3.0.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4806250d9ee4129f2f079da825017f11cbba61f6999508c28e686ddc17974b5a
|
|
| MD5 |
1577054295f6b37c616675699f311608
|
|
| BLAKE2b-256 |
f15fb6eb0cb6b833af8600bd19922297f413fe3d83c73dbf9f23a60abb5e6528
|
File details
Details for the file Wdatabase-2.3.0-py3.10.egg.
File metadata
- Download URL: Wdatabase-2.3.0-py3.10.egg
- Upload date:
- Size: 20.1 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad8164261825f9ac4bed457b1e0a59a777b35501ede3526ff69a44b9d09e1ca6
|
|
| MD5 |
1dce279eb91109a96e3741d130c576bf
|
|
| BLAKE2b-256 |
9237bf150179c225ed21992ba5d3e5d1e72897adda93ae104ca7883449fa71f4
|
File details
Details for the file Wdatabase-2.3.0-py3.9.egg.
File metadata
- Download URL: Wdatabase-2.3.0-py3.9.egg
- Upload date:
- Size: 20.0 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c663b81ab5186deba107030c0424c2f2bde92bf876450405755dccca12ad8047
|
|
| MD5 |
980ff3c6f9c9b2ca23234c033bcd0d9c
|
|
| BLAKE2b-256 |
832ba29431668f90b790ec3c8e5f1fea79d514275eb6c51a6612592cbb361d19
|
File details
Details for the file Wdatabase-2.3.0-py3.8.egg.
File metadata
- Download URL: Wdatabase-2.3.0-py3.8.egg
- Upload date:
- Size: 20.0 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c7bd5cb2d77a562dc0e19c8858df992c7d78ffd297bffa7cdd0067ec85037b2
|
|
| MD5 |
15be8b5b2b4b843406eab2bc9c0016a5
|
|
| BLAKE2b-256 |
3770b45b55f2c43803775155aa182da0b035087e06c0bf4a97b56ffd9a3281bd
|