-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdf_utils.api
10 lines (10 loc) · 6.87 KB
/
df_utils.api
1
2
3
4
5
6
7
8
9
10
du.df_2_sqlite(df, db_path, table_name)\n🏷 Creates a SQLite database file from DataFrame\n\n📌 ARGUMENTS:\n―――――――――――――――――――――――――――――――――――――――――――――――――\n - df (DataFrame)\n - db_path (Path) Database name with path\n - table_name (str) Table name\n\n🎯 RETURNS\n―――――――――――――――――――――――――――――――――――――――――――――――――\n → SQLite file (database)
du.df_2_xlsx(df, fn, sn, ac=1, m=0, s=0, sr=0)\n🏷 Saves Dataframe(s) to worksheet(s) in a single Excel xlsx file.\n\n📌 ARGUMENTS:\n―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――\n- df (DataFrame)\n- fn (Path(str)) File Name\n- sn (str) Sheet Name\n- ac (int) Auto-resize column 0 = Off, 1 = On \n- m (int) Multiple dataframes 0 = Single, 1 = Multi*\n- s (int) Styling 0 = Header, 1 = Table\n\nMulti* = If flag m=1, function expect the list of dataframes \n and list of worksheet names of equal size, and it will\n produce a single xlsx file with multiple worksheets.\n\n🎯 RETURNS:\n―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――\n→ Single xlsx file with worksheet(s)
du.df_dtypes(df, mode)\n🏷 Prints particular DataFrame types\n\n📌 ARGUMENTS:\n――――――――――――――――――――――――――――――――――――\n- df (DataFrame)\n- mode (int)\n 0 = print\n 1 = NUM column list\n 2 = DAT column list\n 3 = TXT column list\n 4 = ALL columns list\n\n🎯 RETURNS:\n――――――――――――――――――――――――――――――――――――\n→ Text data
du.print_df()\n🏷 Prints a DataFrame.\n――――――――――――――――――――――――――――――――――――\n🏁 FLAGS: 1 = ON, 0 = OFF\n\n📌 ARGUMENTS:\n――――――――――――――――――――――――――――――――――――\n- df Dataframe DataFrame\n- d DTypes int\n- dt DTypes tabular int\n- c Columns int\n- v Values int\n- vt Values tabular int 1=simple\n 2=psql\n 3=fancy_grid\n- e Exit after print int\n\n🎯 RETURNS:\n――――――――――――――――――――――――――――――――――――\n→ DataFrame information and values
du.df_append_2_xlsx(df, file_name, sheet_name)\n🏷 Appends data from DataFrame \n to a new worksheet in existing file\n\n⚙️ PREREQUISITES:\n――――――――――――――――――――――――――――――――――――――――――――――――――\npip install openpyxl\n \n📌 ARGUMENTS:\n――――――――――――――――――――――――――――――――――――――――――――――――――\n- df (DataFrame) your data\n- file_name (Path) Existing xlsx file\n- sheet_name (str) Sheet Name for a new data\n\n🎯 RETURNS:\n――――――――――――――――――――――――――――――――――――――――――――――――――\n→ File list
fi.remove_sublist(main_list, unwanted_list)\n🏷 Remove items in sub-list from main list\n\n📌 ARGUMENTS:\n―――――――――――――――――――――――――――――――――――――――――――――――――\n- main_list list from which I want to remove..\n- sub_list ..this istems.\n\n🎯 RETURNS:\n―――――――――――――――――――――――――――――――――――――――――――――――――\n→ Reduced main list
fi.check_sublist(main_list, sub_list, exception=0)\n🏷 Check if list conatins a whole or partial sublist\n\n📌 ARGUMENTS:\n――――――――――――――――――――――――――――――――――――――――――――――――――\n- main_list list in which I try to find..\n- sub_list ..this sub-list\n- exception=0 with exception of n items. \n Default is 0 which means all items \n of sub-list should be in main list \n to get True as a result.\n🎯 RETURNS:\n――――――――――――――――――――――――――――――――――――――――――――――――――\n→ True or False
fi.list_slice (list, chunks)\n🏷 Slice list to smaller and equal pieces \n (exept the last chunk)\n\n📌 ARGUMENTS:\n―――――――――――――――――――――――――――――――――――――――――――――――――――\n- list (list) source list\n- chunks (int) desired number of items in sublist\n\n🎯 RETURNS:\n―――――――――――――――――――――――――――――――――――――――――――――――――――\n→ Nested list of sliced sublist of equal size
fi.replace_many(text, dic)\n🏷 Multiple replacement in given text \n from replacement dictionary\n\n📌 ARGUMENTS:\n――――――――――――――――――――――――――――――――――――――――――――――――\n- text (str) Text which will be changed\n- dic (dictionary) Replace dictionary\n\n🎯 RETURNS:\n――――――――――――――――――――――――――――――――――――――――――――――――\n→ New text
fi.fuzzy_compare_lists(source_list, match_list, limit_level, fast=0)\n🏷 Compare 2 lists using RapidFuzz library \n with Levenstein algorithm\n\n⚙️ PREREQUISITES:\n――――――――――――――――――――――――――――――――――――――――――――――――――――――――\npip install rapidfuzz\n\n📌 ARGUMENTS:\n――――――――――――――――――――――――――――――――――――――――――――――――――――――――\n- source_list (list[str]) Items that we will comapre\n- match_list (list[str]) ...with items from this list\n- limit_level (int) and use n best scores\n- fast (int) scorer is fuzz.QRatio\n\n🎯 RETURNS:\n――――――――――――――――――――――――――――――――――――――――――――――――――――――――\n→ DataFrame