Тёмный

Create Columns in Pandas | Python Pandas Tutorial # 8 | Add, Subtract Columns | Text to Columns 

datagy
Подписаться 5 тыс.
Просмотров 6 тыс.
50% 1

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 21   
@Al-Ahdal
@Al-Ahdal Год назад
Your vdo are interesting and informative. I have walked through but could not found any playlist on "Comprehensive Data Analysis" covering all aspects of reading files from different sources, databases, pdf and do wholistic analysis. Plus this playlist should cover REGEX
@nonitathomas4620
@nonitathomas4620 2 года назад
Is it? df['Number'] = range(1,5)
@datagy
@datagy 2 года назад
That's perfect, Nonita!
@jonathanfriz4410
@jonathanfriz4410 3 года назад
Very good explanation. Thanks. If you can cover how to get the age from a DOB like this 1991-04-24 00:00:00 that would be terrific.
@datagy
@datagy 3 года назад
Hi Jonathan, Great idea! I'll add that to the list. In the meantime, you can use this script: import datetime (datetime.date.today() - datetime.date(1991, 4, 24)).days / 365.25 It calculates the difference (in days) between today and the date, and divides it by 365.25. Hope this helps!
@jonathanfriz4410
@jonathanfriz4410 3 года назад
​@@datagy Thank you!! that works. (the terminal show me the results in days, but the actual .xlsx that I made have the correct results in years). Thank you again big time!
@arpitasen4863
@arpitasen4863 2 года назад
Thank you
@datagy
@datagy 2 года назад
Thanks for your comment!
@IsItBehindTheFridge
@IsItBehindTheFridge 2 года назад
Is it? df['Number'] = range(1,5)
@datagy
@datagy 2 года назад
That's right! 🥳
@sayednab
@sayednab Год назад
what if i dont want to add new columns. but want to multiply and divide within the existing columns?
@datagy
@datagy Год назад
Hi Nab, you could just reassign the column to itself. So to divide column A by five: df[‘A’]=df[‘A’]/5
@ameerhamza-zr5oc
@ameerhamza-zr5oc 4 года назад
sir, I work on football match prediction so when I remove the Full-time home team goal(FTHG) and Full time away from team goal(FTAG) feature than my algorithm accuracy is 66% but when I add FTHG and FTAG feature than my accuracy is above then 90% so what can I do?
@nawelvlogs1981
@nawelvlogs1981 Год назад
I tried this but didn't work I got error😩
@Yeni2503
@Yeni2503 3 года назад
thank u very much! It helps me alot:)
@datagy
@datagy 3 года назад
Thank you! I’m glad it was useful!
@ameerhamza-zr5oc
@ameerhamza-zr5oc 4 года назад
hy sir i need your help
@prashantha14r
@prashantha14r 4 года назад
Thank you for the Tutorial. I found this video very useful and interesting. I have question though, what if we don't know the resulting number of columns? Because, without this information, I can't proceed adding column names onto the dataframe.
@datagy
@datagy 4 года назад
Thanks Prashantha! Can you let me know where you're running into the issue? I'd be happy to help.
@prashantha14r
@prashantha14r 4 года назад
@@datagy Thanks for the reply. In the tutorial video - text to column section, you've created 2 columns knowing that there will be only 2. There could be instances where we might don't know number of delimiter/or varies. for example a Name column cell containing - 3 names separated by ";" -->"Tom Cruise; Sylvester Stallone; Tom Hanks" and in the 2nd cell "Catherina Zeta-Jones; Angelina Jolie"
@datagy
@datagy 4 года назад
@@prashantha14r Hey there! Great question. There are probably much more elegant ways of doing this, but here's one solution! Let me know if you have any troubles. import pandas as pd df = pd.DataFrame.from_dict({'Names': ["Tom Cruise; Sylvester Stallone; Tom Hanks", "Catherina Zeta-Jones; Angelina Jolie"]}) # Count how many columns need to be created (find the maximum number of delimeters that exist, then add 1) number_of_columns = df['Names'].str.count(';').max() + 1 # Create a list of columns using a list comprehension (check out: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ojarZZ5MxBk.html for help) columns = ['name_'+str(i) for i in range(number_of_columns)] # Split columns df[columns] = df['Names'].str.split(';', expand=True) Nik
Далее
ОВР Шоу:  Семейные понты  @ovrshow_tnt
07:21
Pandas - Multiplying Columns To Make A New Column
9:00
ОВР Шоу:  Семейные понты  @ovrshow_tnt
07:21