Given a list of data frames, finds common columns between all pairs of data frames.
Project description
Common Columns Package
This package contains a function called common_columns that can be used to find the common columns between all pairs of data frames.
Installation
To install this package, you can use pip. Open your terminal and run the following command:
pip install common-columns
Usage
To use the common_columns function, you first need to import it from the package:
from common_columns import common_columns The function takes in a variable-length argument list of pandas data frames. Here's an example of how to use it:
import pandas as pd
from common_columns import common_columns
df1 = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
df2 = pd.DataFrame({'B': [7, 8, 9], 'C': [10, 11, 12]})
df3 = pd.DataFrame({'B': [13, 14, 15], 'D': [16, 17, 18]})
common_cols_all = common_columns(df1, df2, df3)
In this example, we have three data frames (df1, df2, and df3). We call the common_columns function with these data frames as arguments, and store the result in the common_cols_all variable. The common_cols_all variable will contain a set of column names that are common to all three data frames, if any.
Function Description
The common_columns function takes in a variable-length argument list of pandas data frames, and returns a set containing the names of columns that are common to all data frames, if any. It works as follows:
Initialize a list of common columns.
Get the names of the data frames, assigning a default name to any data frames without a name attribute.
Loop over all pairs of data frames.
Find the common columns between the two data frames. If there are common columns, add them to the list of common columns.
Find the common columns across all data frames.
Return a set containing the names of columns that are common to all data frames, if any.
Contributing
If you'd like to contribute to this package, please feel free to fork the repository and submit a pull request. We welcome contributions from the community! You can also contact me on my personal email adress: elenagarciamanes@gmail.com
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 Distribution
Hashes for common-cols-project-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6a91cca37f43698c48828e99686ff8fe3b7c1f419626e41481b4748a0f4ed98 |
|
MD5 | 65b260b7694d401c82af6f35105cb9be |
|
BLAKE2b-256 | d08ee99bbc7b52936d63d27f9d34cd12fbb6aa498cca8d5a1faa5975588e7d88 |
Hashes for common_cols_project-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f023700a35f607c965884012f315a9e42f797cc4bedb919da1dead17536b67f |
|
MD5 | 019b0e469de16e9e9657570993eaf5c6 |
|
BLAKE2b-256 | d8e4b4f54aec86ab789d1ee7703a2ea40c5c120c8bfd4084298dc95164022ccd |