Pandas Tutorial : How to split columns of dataframe

preview_player
Показать описание
Pandas Tutorial : How to split columns of dataframe

Machine Learning Cheatsheet

import pandas as pd

df = pd.DataFrame({'Company': ['Samsung', 'Samsung', 'Samsung', 'Samsung', 'Samsung',
'LG', 'LG', 'LG', 'LG', 'LG', 'Sony', 'Sony', 'Sony',
'Sony', 'Sony'],
'Date': ['10/9/2018', '10/9/2018', '10/9/2018', '10/10/2018',
'10/10/2018', '10/10/2018', '10/9/2018', '10/9/2018',
'10/9/2018', '10/10/2018', '10/10/2018', '10/10/2018',
'10/10/2018', '10/10/2018', '10/10/2018'],
'Country': ['India', 'India', 'USA', 'France', 'India', 'India',
'Germany', 'USA', 'Brazil', 'Brazil', 'India', 'Germany',
'India', 'India', 'Brazil'],
'Sells': [15, 81, 29, 33, 21, 42, 67, 35, 2, 34, 21, 50, 10, 26, 53]})

# creating new dataframe single column

# expand to new columns

# limit the split to first one

# adding new columns to the old dataframe

a = 1

Code store

Socials

If you really find this channel useful and enjoy the content, you're welcome to support me and this channel with a small donation via PayPal.

Рекомендации по теме
Комментарии
Автор

what do you do if you dont have a column name, how do you reference a column without a header.

corbnatkinson
Автор

Great tutorial buddy, thank you. I had this exact problem where i had monthly averages and thus had for every year, 12 rows. Now I am trying to create 1 row per year with the monthly values in 12 columns. Would you know of any documentation or video which could help me create such a matrix?

Carlos
Автор

Great small tut. I was wondering about your IDE? Which one is it? Can you do more videos using csv files with multiple delimeters. Many thanks. 😊👍

jaimedpcaus
Автор

I am a beginner. I have a dataframe having a column named "Size" with values 10MB, 12KB, 5GB .... I want to split this column into two columns separating integer from string for analysis. like 10, 12, 5 ... and MB, KB, GB Kindly help.

thelearninglab
Автор

Hi, thank you for the video!

I am wondering how would you do that if the data to be split were disorderly, for example:
'Date' : ['month/day/'year', 'year/day/month', 'day/year/month', 'year/month', 'day', 'missing value']

And you need to split into 3 columns orderly: (month, day, year)

If you could give me a clue on this would be great

Best regards!

federicolucca
Автор

Thanks for your video its helpfull. For Eg: Anand786 How do i split it into "Anand" and "786"

anandpatil