-2

after my code is finished, I'm trying to improve the readability.

Can you help me to improve the readability of the following lines according to PEP 8 regarding the 80 character limit?

You see, the part == 'Geburtsdatum' is behind the border.

def function(x, y):      
    try:
        ...
        
        # Iterate over each row anch check if we use it in our file
        for i in range((dfs[0].shape[0])): 

            if str(dfs[0].at[dfs[0].index[i],dfs[0].columns[0]]).replace(':', '') == 'Geburtsdatum':
                df.at[df.index[0],df.columns[3]] = dfs[0].at[dfs[0].index[i],dfs[0].columns[1]]

enter image description here

TylerH
  • 20,799
  • 66
  • 75
  • 101
edstrinova
  • 101
  • 1
  • 7

1 Answers1

1
  1. You could make your own function that will perform the string conversion, replacing and checking, taking in dfs[0].at[dfs[0].index[i],dfs[0].columns[0]] and Geburtsdam (and the other values) ; it should save you some characters.

  2. You could assign dfs[0].columns to a variable cols and dfs[0].index to a variable idx, and other changes like this.

  3. You could also just do a line break in the middle of the line with \.

OctaveL
  • 1,017
  • 8
  • 18