<jupyter_start><jupyter_text>upto this point the code blocks runs once, but the below blocks run multiple times<jupyter_code>tables[4][4].df
s1=pd.Series([0,1,2,3,4,5,6,7])
s2=pd.Series([0,1,2,3,4,5,6,7,8])
s3=pd.Series([0,1,2,3,4,5,6,7,8,9,10])
s4=pd.Series([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])
tables[4][4].df=tables[4][4].df.set_index(s1)        # restructing the table number 4
tables[4][4].df
for i in range(1,11):
    tables[4][i].df.drop(0,axis=1,inplace=True)  # change tables[this value should be changed][]
frames=[]
for i in range(0,11):
    frames.append(tables[4][i].df)  # change tables[this value should be changed][]
result=pd.concat(frames,axis=1, ignore_index=True)
#import re
#import io
#import pandas as pd
import numpy as np

#with open('merged1.csv','r') as f:
 #   data = f.read()
#df = pd.read_csv(io.StringIO(re.sub('"\s*\n','"',data)))
df=result
for col in df.columns: #To replace all line breaks in all textual columns
    if df[col].dtype == np.object_:
        df[col] = df[col].str.replace('\n','');
df
x=(df.columns)   # x = old column heading # it also runs once
y=list(df.iloc[0])   # actual column headings # it also runs once only

d = dict(zip(x,y))                # coping column names into pandas column name and deleting the duplcate column name
df_new = df.rename(columns=d)
df_new.drop(0,inplace=True)


df_new
df_new.to_csv("4.csv",index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18092566619915848, 'fraction_numerical': 0.05890603085553997, 'mean_word_length': 5.124463519313305, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '474083', 'license': 'MIT', 'n_tokens_mistral': 599, 'n_tokens_neox': 578, 'n_words': 129, 'path': 'to_build_comp_csv.ipynb', 'repo_name': 'Arnab12345/PDF_to_CSV', 'size': '1426'}