Python CSV files - with PANDAS

  Рет қаралды 109,469

John Watson Rooney

John Watson Rooney

Күн бұрын

Learn the basics of manipulating CSV files with Pandas in Python. Take order information and split it out based on criteria
-------------------------------------
twitter / jhnwr
code editor code.visualstu...
WSL2 (linux on windows) docs.microsoft...
-------------------------------------
Disclaimer: These are affiliate links and as an Amazon Associate I earn from qualifying purchases
mouse amzn.to/2SH1ssK
27" monitor amzn.to/2GAH4r9
24" monitor (vertical) amzn.to/3jIFamt
dual monitor arm amzn.to/3lyFS6s
microphone amzn.to/36TbaAW
mic arm amzn.to/33NJI5v
audio interface amzn.to/2FlnfU0
keyboard amzn.to/2SKrjQA
lights amzn.to/2GN7INg
webcam amzn.to/2SJHopS
camera amzn.to/3iVIJol
gfx card amzn.to/2SKYraW
ssd amzn.to/3lAjMAy

Пікірлер: 48
@EndBL
@EndBL Жыл бұрын
thank you John! can't wait to watch harder videos about panda csv
@markhamilton1292
@markhamilton1292 3 жыл бұрын
Direct and to the point, well done!
@kanwisher
@kanwisher 10 ай бұрын
Clear and easy, just what I was looking for
@bengray1054
@bengray1054 6 ай бұрын
This video is awesome. I am a novice at python and so far NOTHING has come as close to this video in terms of showcasing just how simple pandas makes reading data!
@auggiea9195
@auggiea9195 Жыл бұрын
Just started learning Python for my degree 2 weeks ago and this was so helpful! Thank you!!
@abd5184
@abd5184 Жыл бұрын
Tough British accent
@dicasdetop
@dicasdetop 5 ай бұрын
man, honestly i appreciate your video, I loving coding with you, wish you, a good person, stay safe always
@hannahreynolds2800
@hannahreynolds2800 2 жыл бұрын
Would there be a reason why my program keeps saying I have an empty dataframe when I do not
@nseworld5521
@nseworld5521 Жыл бұрын
thank you man! you know, it`s first time i`m using python in my entry to data analytics) i thought it would be much harder to understand code, but the way you give information makes me feel so ez
@uteshiyadharmesh
@uteshiyadharmesh 2 ай бұрын
Exact whatever I was looking for to quick start my pandas journey! Thanks for such an awesome video! Love it!
@yasseralkindi7350
@yasseralkindi7350 3 жыл бұрын
Great video as always John - thank you. Off the cuff question here - can you do a video on troubleshooting csv imports with pandas? When I've imported a csv file, and df.head(), it sometimes brings in a single column and an index. Other times, it works exactly as expected. Since I don't know what to do with that column, I thought such a video might help?
@isabellaj4608
@isabellaj4608 5 ай бұрын
man you saved my assignment with 5:12 I couldn't understand how to do it for the life of me lol
@yanwenwei5462
@yanwenwei5462 3 жыл бұрын
Thank you, John. It helped my assignment.
@andreha_
@andreha_ 3 жыл бұрын
Video so cool but I have a question. I need to check 2 parameters in two deferent columns how I can do that?
@MachineLearningPro
@MachineLearningPro 10 ай бұрын
Great video mate! Take a look at my pandas tutorial if you want.
@burkhardleuthner9208
@burkhardleuthner9208 Жыл бұрын
Hi, John. Thanks for shareing this video. In the beginning you spoke about the src-file "address-data.csv". Could you please share the link from the source?? I didn't get that!
@JohnWatsonRooney
@JohnWatsonRooney Жыл бұрын
hey, thanks for watching. I'd love to but i made this 3 years ago I don't have any of it any more sorry!
@onkarnardekar6491
@onkarnardekar6491 2 жыл бұрын
Thankyou Soooo Muchhh for this video
@technikalproblem6780
@technikalproblem6780 2 жыл бұрын
Thank you so much! This worked.
@sheikhm9407
@sheikhm9407 Жыл бұрын
Great!!
@jholmes724
@jholmes724 2 жыл бұрын
Get video, short and to the point. Now do some guitar tutorials, I'll join you. lol
@JohnWatsonRooney
@JohnWatsonRooney 2 жыл бұрын
Haha sure!
@ZyngastiC
@ZyngastiC 29 күн бұрын
Thanks!!!!
@anurajms
@anurajms 2 жыл бұрын
thank you
@sabinomuniz5542
@sabinomuniz5542 9 ай бұрын
How can I get the data from a csv file without rewriting all of it to my python program?
@atetetega2468
@atetetega2468 3 ай бұрын
Your raw data
@breandensamas8623
@breandensamas8623 2 ай бұрын
Good one
@saisanthosh8370
@saisanthosh8370 3 жыл бұрын
deserved more subs
@adamstephan168
@adamstephan168 2 жыл бұрын
Awesome video, in this example, if I wanted to move all the '1 Day' and '2 Day' labeled shipping types into the a dataframe titled 'Early_Shipping', how would I write that code?
@jayyvibing9539
@jayyvibing9539 Жыл бұрын
1. Import the necessary modules: import csv 2 . Open the .csv file in write mode and create a csv.writer object: with open('shipping_times.csv', 'w', newline='') as csvfile: writer = csv.writer(csvfile) 3. Iterate over the rows in the dataset and write the desired rows to the 'Early shipping' column in the .csv file: for row in dataset: if row[0] == 'Day 1' or row[0] == 'Day 2': writer.writerow(['Early shipping'] + row[1:]) else: writer.writerow(row) This will write the 'Day 1' and 'Day 2' shipping times to the 'Early shipping' column in the .csv file, and leave the other rows unchanged. Note that this assumes that the shipping times are in the first column of the dataset, and that the .csv file has a header row with the column names. If this is not the case, you may need to modify the code accordingly.
@jayyvibing9539
@jayyvibing9539 Жыл бұрын
My other comment provides more information: To create a pandas DataFrame with the 'Day 1' and 'Day 2' shipping times under a column called 'Early shipping', you can use the following steps: 1. Import the necessary modules: import pandas as pd 2. Create a list of the desired rows from the dataset: early_shipping = [row for row in dataset if row[0] == 'Day 1' or row[0] == 'Day 2'] 3. Create a DataFrame from the list of rows: df = pd.DataFrame(early_shipping, columns=['Early shipping']) 4. This will create a DataFrame with a single column called 'Early shipping' and one row for each 'Day 1' or 'Day 2' shipping time in the dataset. If you want to include other columns from the dataset in the DataFrame, you can specify them in the columns parameter of the pd.DataFrame constructor. For example: df = pd.DataFrame(early_shipping, columns=['Early shipping', 'Other Column', 'Another Column']) This will create a DataFrame with three columns: 'Early shipping', 'Other Column', and 'Another Column'. The values in the 'Early shipping' column will be the 'Day 1' and 'Day 2' shipping times, and the values in the other columns will be taken from the corresponding columns in the dataset.
@jayyvibing9539
@jayyvibing9539 Жыл бұрын
To combine the two scripts, you can do the following: 1. Import the necessary modules: import csv import pandas as pd 2. Open the .csv file in write mode and create a csv.writer object: with open('shipping_times.csv', 'w', newline='') as csvfile: writer = csv.writer(csvfile) Iterate over the rows in the dataset and write the desired rows to the 'Early shipping' column in the .csv file: Copy code for row in dataset: if row[0] == 'Day 1' or row[0] == 'Day 2': writer.writerow(['Early shipping'] + row[1:]) else: writer.writerow(row) 3. Create a list of the desired rows from the dataset: early_shipping = [row for row in dataset if row[0] == 'Day 1' or row[0] == 'Day 2'] 4. Create a DataFrame from the list of rows: df = pd.DataFrame(early_shipping, columns=['Early shipping']) df = pd.DataFrame(early_shipping, columns=['Early shipping', 'Other Column', 'Another Column']) This will first write the 'Day 1' and 'Day 2' shipping times to the 'Early shipping' column in the .csv file, and then create a DataFrame with the 'Day 1' and 'Day 2' shipping times under a column called 'Early shipping'. If you specify additional columns in the columns parameter of the pd.DataFrame constructor, the DataFrame will include those columns as well.
@Soler4485
@Soler4485 Жыл бұрын
So I am trying to create a pdf file from a csv file but I want to create a code that can take any csv which is inputted into it to create a different pdf depending on the content of the csv. Do you know of any way to do that? I know that to convert to pdfs you need the pdfkit plugin which I have and I have done but I am just not sure how to make the code generalizable.
@dzeykop
@dzeykop 3 жыл бұрын
Thank you John, 👏👍
@python360
@python360 4 жыл бұрын
Jupyter notebook is great way of working with Pandas - maybe do a vid on that too?
@JohnWatsonRooney
@JohnWatsonRooney 4 жыл бұрын
Great idea, I love Jupyter
@saifazeem8158
@saifazeem8158 3 жыл бұрын
Quite useful, Keep up the good work! ❤️
@JohnWatsonRooney
@JohnWatsonRooney 3 жыл бұрын
Thank you! 🙂
@ThiagoSimoes79
@ThiagoSimoes79 Жыл бұрын
Thanks mate. Help me a lot.
@JohnWatsonRooney
@JohnWatsonRooney Жыл бұрын
Happy to help
@burkhardleuthner9208
@burkhardleuthner9208 Жыл бұрын
Src-File ?
@simbarashechibgwe4497
@simbarashechibgwe4497 3 жыл бұрын
Thanks John
@lutfullayuldashev6278
@lutfullayuldashev6278 3 жыл бұрын
Hi John. I m new to python. Still struggling to choose appropriate python application. Tending to use jupyter, however yours look more interesting. Can you please tell the name of this python application (interface)?
@JohnWatsonRooney
@JohnWatsonRooney 3 жыл бұрын
Sure, its' VS Code. It's free. I did a video on a basic Windows Python setup here: kzbin.info/www/bejne/e3u4lXl4as6obbs if you are interested.
@lutfullayuldashev6278
@lutfullayuldashev6278 3 жыл бұрын
@@JohnWatsonRooney thanks for response!
@aces9905
@aces9905 2 жыл бұрын
Helpful! How do I find the most repeated word in my file?
@jayyvibing9539
@jayyvibing9539 Жыл бұрын
Here is one way to find the most repeated word in a .csv file in Python: 1. First, open the .csv file using the csv module and create a list of the words in the file. 2. Use the Counter function from the collections module to count the frequency of each word. 3. Find the word with the highest frequency by using the most_common method of the Counter object. Here is some example code that demonstrates this approach: import csv from collections import Counter # Open the .csv file and create a list of the words in the file with open('file.csv', 'r') as f: reader = csv.reader(f) words = [] for row in reader: for word in row: words.append(word) # Count the frequency of each word word_counts = Counter(words) # Find the word with the highest frequency most_common_word = word_counts.most_common(1)[0][0] print(f"The most common word is: {most_common_word}") This code will open the .csv file, read the contents into a list of words, count the frequency of each word using the Counter function, and then find the word with the highest frequency using the most_common method. The output will be the most common word in the file. Note that this code assumes that each row in the .csv file represents a list of words separated by commas. If your .csv file has a different structure, you may need to modify the code to suit your needs.
@juzarpara5357
@juzarpara5357 4 жыл бұрын
With below code I am able to create dataframe VAT = comm[comm['Particulars'].str.contains("comm|Britain", case=False)==True] VAT But I want to create column below code does not work comm['VAT'] = comm[comm['Particulars'].str.contains("comm|Britain", case=False)==True] comm Can you provide proper code ?
Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
16:12
This is How I Scrape 99% of Sites
18:27
John Watson Rooney
Рет қаралды 97 М.
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 57 МЛН
🍉😋 #shorts
00:24
Денис Кукояка
Рет қаралды 3,7 МЛН
This INCREDIBLE trick will speed up your data processes.
12:54
Rob Mulla
Рет қаралды 265 М.
Turning multiple CSV files into a single pandas data frame
8:09
Python and Pandas with Reuven Lerner
Рет қаралды 30 М.
The six most important read_csv arguments in Pandas
16:50
Python and Pandas with Reuven Lerner
Рет қаралды 3,2 М.
Exploratory Data Analysis with Pandas Python
40:22
Rob Mulla
Рет қаралды 477 М.
What is Pandas? Why and How to Use Pandas in Python
10:08
Python Programmer
Рет қаралды 606 М.
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
Rob Mulla
Рет қаралды 271 М.
Are You Still Using Excel? AUTOMATE it with PYTHON
7:19
John Watson Rooney
Рет қаралды 49 М.
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 57 МЛН