0
    #Create list to store all not null URL values 
    URL_vals = []
    
# Create List of Just URL Columns
URL_col = df[['Graphic URL 2','Graphic URL 3','Graphic URL 4','Fact Sheet URL','Fact Sheet URL 2','Fact Sheet URL 3','Fact Sheet URL 4',
                  'Fact Sheet URL 5','Fact Sheet URL 6','Fact Sheet URL 7','Fact Sheet URL 8','Stats for Stories URL','Stats for Stories URL 2',
                  'Stats for Stories URL 3','Stats for Stories URL 4','Stats for Stories URL 5','Stats for Stories URL 6',
                  'Stats for Stories URL 7','Stats for Stories URL 8','Facebook Content URL','Instagram Content URL','Twitter Content URL',
                  'News Product URL','Press Release URL','Press Release URL 2','Press Release URL 3','Press Release URL 4',
                  'Press Release URL 5','Press Release URL 6','Press Release URL 7','Press Release URL 8','America Count URL','America Counts URL 2',
                  'America Counts URL 3','America Counts URL 4','America Counts URL 5','America Counts URL 6','America Counts URL 7','America Counts URL 8',
                  'Census Blog URL','Census Blog URL 2','Census Blog URL 3','Census Blog URL 4','Census Blog URL 5','Census Blog URL 6',
                  'Census Blog URL 7','Census Blog URL 8','Graphic URL']]   

 # Loop through rows and grab string values that are not null. Append them to the URL_vals list
    for i in URL_col.iterrows():
        if np.string_(i):
            URL_vals.append(i)
            ++i 

I am getting this error in response: ValueError: setting an array element with a sequence.

How can I fix this?

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • 1
    `++i` isn't valid Python syntax; use `i += 1` instead. – BrokenBenchmark Apr 05 '22 at 20:02
  • 1
    Please share the complete stack trace, and mind the indentation when you put Python code in a question, since indentation is part of the syntax in Python. – joanis Apr 05 '22 at 20:05
  • Traceback (most recent call last): File "", line 1, in runfile('C:/Users/.spyder-py3/untitled0.py', wdir='C:/Users/.spyder-py3') File "C:\Anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile execfile(filename, namespace) File "C:/Users/.spyder-py3/untitled0.py", line 64, in if np.string_(i): ValueError: setting an array element with a sequence – domledonne Apr 05 '22 at 20:14
  • Can you share the first few rows of URL_col? – constantstranger Apr 05 '22 at 23:14
  • 1
    @Broken It is valid actually, but it doesn't do anything. It's parsed as `+(+(i))` -- unary positive. – wjandrea Apr 06 '22 at 00:50
  • @domledonne Please [edit] the question to add it. Comments don't support fancy formatting. BTW, I recommend taking the [tour] and reading [ask], [mre], and [How to make good reproducible pandas examples](/q/20109391/4518341). – wjandrea Apr 06 '22 at 00:53

0 Answers0