| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
- machine learning
- pie charts
- iterates
- break
- line width
- PROJECT
- Python
- matplotlib
- error
- matplotlib.pyplot
- Text Analytics
- AS
- multiple lines
- PANDAS
- Github
- Text mining
- self parameter
- Default X points
- __init__
- train/test
- variables
- start exercise
- Else
- data distribution
- polynomial regression
- MySQL
- SQL
- continue
- For loops
- line color
- Today
- Total
목록Python (42)
Data Science Explorer
Sometimes our data might not be in the format we expect. For example, numbers might be stored as text, or dates might not be recognized as dates. We need to identify these issues. Convert into a Correct Format Example Convert the 'Age' column to numbers. df['Age'] = pd.to_numeric (df['Age'], errors = 'coerce') ** The 'errors' parameter helps handle cases where the conversion isn't possible, and ..
Remove Cells If there are some empty rosws, you would want to remove them. Example Return a new Data Frame with no empty cells. import pandas as pd df = pd.read_csv('hello.csv') new_df = df.dropna() print(new_df.to_string()) ** dropna() method returns a new Dataframe, not changing the original one. ** When you want to keep the orignial dataframe, use the inplace = True argument. Example Remove a..
CSV files (comma separated files) are used to store big data sets. Example Load the CSV into a DataFrame. import pandas as pd df = pd.read_csv('data.csv') print(df.to_string()) ** to_string() is to print the entire DataFrame. ** max_rows If you want to check your system's max rows with the pd.options.display.max_rows statement. Example Check the number of maximum returned rows. import pandas as ..
What is a DataFrame? A Pandas DataFrame is a 2 dimensional data structure, like a 2 dimensional array, or a table with rows and columns. Example You are tasked with creating a Pandas DataFrame to represent student information. The DataFrame should include columns for "StudentID," "Name," "Age," and "Grade." Create a Pandas DataFrame with the following data. | StudentID | Name | Age | Grade | |--..
A Pandas series is like a column in a table. import pandas as pd a = [1, 7, 2] myvar = pd.Series(a) print(myvar) 0 1 1 7 2 2 dtype: int64 Create Labels Example import pandas as pd a = [1, 7, 2] myvar = pd.Series(a, index = ["x", "y", "z"]) print(myvar) x 1 y 7 z 2 dtype: int64 Key/Value Objects as Series Example Create a Series using only data from "day1" and "day2". import pandas as pd calories..
What is Pandas? It is a python library for analyzing, cleaning, exploring, and manipulating data. Installation of Pandas C:\Users\Your Name>pip install pandas Import Pandas import pandas as pd Checking Pandas Version import pandas as pd print(pd.__version__)
Upper Case Example The upper() method returns the string in upper case. a = "Good Morning!" print(a.upper()) Lower Case Example The lower() method returns the string in lower case. a = "Good Morning!" print(a.lower()) Remove Whitespace Whitespace is the space before and/or after the actual text and if you want to remove it, you can use strip(). a = " Good Night! " print(a.strip()) # returns "Goo..
Slicing You can return a range of characters by using slice syntax and should specify the start index and end index. Example Get the characters from position 1 to position 3 (not included): b = "Hello, World!" print(b[1:3]) Slice from the Start b = "Christmas" print(b[:5]) Slice to the End b = "Christmas" print(b[:8]) Negative Indexing b = "Hello, World!" print(b[-5:-2]) Exercises Please solve t..
When you use strings in python, they are surrounded by either single quotation marks or double quotation marks. Example print ("Hello") Strings are Arrays Example a = "Good Morning!" print(a[1]) o This is because a[1] is the first index number which is o. Looping Through a String Since strings are arryas, we can loop through the characters in a string within a for loop. for x in "blueberry": pri..
Array 3 An array is a special variable, which can hold more than one value at a time. Access the elements of an array Refer to the index number. Example colors = ["white", "blue", "red"] x = colors[0] print (x) white Change the value of third array item. colors = ["white", "blue", "red"] colors[2] = "black" print (colors) ['white', 'blue', 'black'] The length of an array Use len () to get a resu..