loops

Iterate through chunks of a pandas Dataframe

Iterate through chunks of a pandas Dataframe Question: I have a pandas.DataFrame that looks like the following: Week Monday Tuesday Wednesday Thursday Friday City A 100 300 x z w City B 200 400 y q p None None None None None None Week Monday Tuesday Wednesday Thursday Friday City A 150 320 a c …

Total answers: 2

python printing out a file with a suffix range of 12

python printing out a file with a suffix range of 12 Question: So I have been trying to get a filename to end with a repeat of 01-12, then start over. Any help would be appreciated. def rname(f=None): os.chdir(dir_path) print("Renaming Files.") print(os.getcwd()) for count, f in enumerate(os.listdir()): f_name = os.path.splitext(f)[0] ext_name = os.path.splitext(f)[1] br = …

Total answers: 1

Create one long string from multiple lists of strings

Create one long string from multiple lists of strings Question: I am writing this back-end code to filter through a dataframe using df.query(). I have two lists from which I need to make this new string which will be passed as the query. Can anyone help me out? list1 = [‘Product == "Dress"’, ‘Product == …

Total answers: 4

update column values based on length temp dataframes based on source dataframe

update column values based on length temp dataframes based on source dataframe Question: I have a data: ID closed set message_time aaa 22:00 19:00 19:05 aaa 22:00 19:30 19:40 aaa 22:00 20:00 21:00 bbb 23:00 22:00 22:10 ccc 22:00 19:00 19:05 ccc 22:00 19:30 19:40 code is here: import pandas as pd df = pd.DataFrame({ …

Total answers: 1