As the web gained popularity, a gradual demand for client-side scripting languages developed. At the time, most Internet users were connecting over a 28.8 kbps modem even though web pages were…
After Numpy library, I will explain what Pandas library is, why useful and why we should use this.
Pandas library created for studying data frames. So, what is data frames? Data frames are excel files, this files has datas.
In Pandas, transition from file to file (.csv or .txt files) is easy. Also examining and saving files easy too.
Files can have missing values. If you studying with real world datas, you can see that. But that’s not problem on Pandas.
Pandas usually using with time series too. If you go to the link following, you can see what time series:
Let’s look at Pandas a little more!
Firstly we importing the pandas library in our project with import pandas as pd. Than, we’ll creating a dictionary for example. Like this:
dictionary = {“NAME”:[“Ali”,”Veli”,”Kenan”,”Hilal”,”Ayse”,”Evren”],
“AGE”:[15,16,17,33,45,66],
“SALARY”:[100,150,240,350,110,220]
}
For using Pandas, we have to transform this dictionary to a data frame. If we write dataFrame1 = pd.DataFrame(dictionary) in our code we can use that.
You don’t have to use Spyder to writing codes, but if you do, you can see this in variable explorer:
You can see the diffrence between dictionary and data frame.
This data frame is too small but in real world’s datas are complicated. So if we want to see data frame’s first 5 datas, just need to write dataFrame1.head(). After that, you can print and see data.
Also for see data’s last 5 record, we will write dataFrame1.tail().
dataFrame1 = pd.DataFrame(dictionary)
dataFrame1.columns
This code gets column names (name,age,salary), It’s important because we need this about filtering
dataFrame1.info()
This code gets dataframe type, samples in dataframe, index, data types, memory usage, count of column and their names (except index).
dataFrame1.dtypes gets dataframe type.
dataFrame1.describe() gets numeric features. Like columns’s count, mean, min, max etc.
Now, we will going to details
If we want to see just special column in data frame, for example NAME column, we’ll write dataFrame1[“NAME”] or dataFrame1.NAME.
So, let’s look what to do for creating a new column:
There’s important think, our column’s name haven’t got space. If we do that, It’s not an error but if we write like dataFrame1.New Feature, it has an error.
Our data frame look like this, now:
If you know about SQL, our new subject is like that. Filtering data is important in Data Science.
filtre1 = dataFrame1.SALARY > 200
This code filter our data to salary.
.concat function concatinate our diffrent datas to vertical or horizontal.
That’s it, now we will know about Pandas mostly. Thanks to reading!
NOTE: In pandas, we use object. Object means string. So, if you write type(variable), you can see object type.
Some nights I work all through and have little or no time to sleep, well for one I have so many persons counting on me and I just cannot afford to fail and then I have very limited time to get things… Read more
Chatbots are Crazy these days. It's like everyone is talking about it and very few people out there, who actually knows how to build one. About me: I believe in Innovation in the field of Computer… Read more
If you can keep your head when all about you. “My Journey Starts Today” is published by Ikhtiar. Read more