Q:

Using langdetect output to be imported into a new column in my dataframe

Being rather new to programming with python I tried to language detect segments of text in pandas data frame. 
So first I made a function for the 'langdetect' package
import pandas as pd
from langdetect import detect

def language_detect(x):
    lang = detect(x)
    print(lang)

My second step would be to feed in the data frame for processing. All the segments that need detecting are in separate rows in the dataframe under the same column header.
result = [language_detect(x) for x in df['column_name']]

df['l_detect'] = pd.append(result)

In the output I see the texts being recognized properly.
But when I try to print result.
it returns me with only the value for every entry 'none'
So my questions are: 

why do I get 'none' when the the print output from the function has the right values
How can I attach this to my current data frame, since when I try to append it I get 'none' on 
  every field as well.

Thanks in advance.

A:

The problem is that result is empty because your function language_detect() doesn't return anything (it is only printing the results). 
import pandas as pd
from langdetect import detect

lst = [('this is a test', 1), ('what language is this?', 4), ('stackoverflow is a website', 23)]
df = pd.DataFrame(lst, columns = ['text', 'something'])

def language_detect(x):
    lang = detect(x)
    print(lang)

result = [language_detect(x) for x in df['text']]
result
#Output:[None, None, None]

Just give it a return value:
def language_detect(x):
    lang = detect(x)
    return lang

df['l_detect'] = df['text'].apply(language_detect)

df.head()
#Output:
#                         text  something l_detect
#0              this is a test          1       en
#1      what language is this?          4       en
#2  stackoverflow is a website         23       en

and it will work as expected.

