Skip to main content

feilian

General data processing tool.

Features

  • More default values, less necessary arg.
  • Encapsulation of panda dataframe for simple usage.

Usage

Process data with pandas dataframe

Read a file as dataframe

import feilian

input_file = ''     # file can be any csv, json, parquet or xlsx format
df = feilian.read_dataframe(input_file)

Write dataframe to a file

import feilian
import pandas as pd

df = pd.DataFrame(dict(a=[1, 2, 3], b=[4, 5, 6]))
output_file = ''  # file can be any csv, json, parquet or xlsx format
feilian.save_dataframe(output_file, df)

Iter a dataframe with a progress bar

import feilian
import pandas as pd

df = pd.DataFrame(dict(a=[1, 2, 3], b=[4, 5, 6]))
feilian.iter_dataframe(data=df, progress_bar="process")

Extract sample from a dataframe

import feilian
import pandas as pd

df = pd.DataFrame(dict(a=[1, 2, 3], b=[4, 5, 6]))
sample = feilian.extract_dataframe_sample(df, filter_func=lambda row: row['a'] > 1, size=2, shuffle=True)

Test text value in dataframe

import feilian

s = ''

# test if s is na or empty string
feilian.is_empty_text(s)

# test if s is not na and non-empty string
feilian.is_nonempty_text(s)

# test if s is na or blank string
feilian.is_blank_text(s)

# test if s is not na and non-blank string
feilian.is_non_blank_text(s)

Merge same id rows to one row

import feilian
import pandas as pd

df = pd.DataFrame([
    {"a": "1", "b": "2", "c": "5"},
    {"a": "2", "b": 6, "c": "8"},
    {"a": "1", "b": 8, "c": "9"},
])

res = feilian.merge_dataframe_rows(df, col_id="a", join_sep=",")

IO for json file

Read a json file

import feilian

input_file = ''
data = feilian.read_json(input_file)

Write a json file

import feilian

data = [
    {"a": "1", "b": "2", "c": "5"},
    {"a": "2", "b": 6, "c": "8"},
    {"a": "1", "b": 8, "c": "9"},
]
output_file = ''
feilian.save_json(output_file, data)

Datetime format

import feilian
import datetime

d = datetime.datetime.now()

# format a date string
feilian.format_date(d, sep='-')

# format a time string
feilian.format_time(d, fmt='%H:%M:%S')

Process dict

Flatten dict value

import feilian

data = {
    "a": 12,
    "b": ["4", "s"],
    "c": {
        "l": 0,
        "j": {
            "se": "we",
            "t": 5,
        }
    },
    "f": 7,
    "g": {
        "ts": "9w",
        "j2": 8,
    },
    "w": {
        "s": {
            "ge": 89,
            "00": "ej",
        },
        "r": {
            "le": 33,
            "03": "ef",
        }
    },
    "sk": {
        "a": "23",
        "b": {
            "s": 9,
            "g": 0,
            "p": 4,
        },
        "c": {
            "s": 8,
            "t": "w",
            "j": "23",
        }
    },
}
res = feilian.flatten_dict(data, frozen={"g", "w.s", "sk."}, exclude="f")

Process args

from feilian import ArgValueParser

value = ''

# split value
ArgValueParser.split_strs_to_list(value)
ArgValueParser.split_strs_to_set(value)

# bound value
ArgValueParser.bound_set_if_singleton(value)
ArgValueParser.bound_tuple_if_singleton(value)
ArgValueParser.bound_list_if_singleton(value)

# force value type
ArgValueParser.ensure_set(value)
ArgValueParser.ensure_list(value)
ArgValueParser.ensure_tuple(value)

Metadata

Release files for feilian 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for feilian 1.4.0
File Size Uploaded Provenance Actions
feilian-1.4.0.tar.gz 16.3 kB Without provenance Details for feilian-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for feilian 1.4.0
File Interpreter ABI Platform Actions
feilian-1.4.0-py3-none-any.whl Python 3 none any Details for feilian-1.4.0-py3-none-any.whl

Total release size: 34.8 kB

Release files / feilian-1.4.0.tar.gz

Download URL feilian-1.4.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
37b2160f08d88c0221095be28a6e1aaaac6a23410ffdce61400c7e210c591aab
BLAKE2b-256 checksum
How to use checksums
4f1a31b119621cb89b14282a63e364b27bfb0b84d5fd585db8d225a7cba5310e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / feilian-1.4.0-py3-none-any.whl

Download URL feilian-1.4.0-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
acca2b364ebf354f276b055cfd4c1db3aead65687ec89949456da1b2a41adcbb
BLAKE2b-256 checksum
How to use checksums
4f28c3f38c5a6a071fecfaef4fb6c010ab39d5fa96ac973c29bf90f31cd9ca03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for feilian 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page