Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
st.title("PANDAS")
|
6 |
+
st.subheader("What is pandas?")
|
7 |
+
st.markdown("Pandas is a Python library used for working with data sets.")
|
8 |
+
st.markdown("It has functions for analyzing, cleaning, exploring, and manipulating data.")
|
9 |
+
st.markdown("The name Pandas has a reference to both Panel Data, and Python Data Analysis")
|
10 |
+
st.subheader("Why Use Pandas?")
|
11 |
+
st.markdown("Pandas allows us to analyze big data and make conclusions based on statistical theories.")
|
12 |
+
st.markdown("Pandas can clean messy data sets, and make them readable and relevant.")
|
13 |
+
st.markdown("Relevant data is very important in data science.")
|
14 |
+
st.subheader("What Can Pandas Do?")
|
15 |
+
st.markdown("Pandas gives you answers about the data. Like:")
|
16 |
+
st.write("Is there a correlation between two or more columns?")
|
17 |
+
st.markdown("What is average value?")
|
18 |
+
st.markdown("Max value?")
|
19 |
+
st.markdown("Min value?")
|
20 |
+
st.subheader("what is cleaning data:")
|
21 |
+
st.markdown("Pandas are also able to delete rows that are not relevant, or contains wrong values, like empty or NULL values. This is called cleaning the data.")
|
22 |
+
st.subheader("Installation of Pandas")
|
23 |
+
st.markdown("If you have Python and PIP already installed on a system, then installation of Pandas is very easy.")
|
24 |
+
st.markdown("or use a python distribution that already has Pandas installed like, Anaconda, Spyder etc.")
|
25 |
+
st.subheader("import pandas:")
|
26 |
+
st.markdown("Once Pandas is installed, import it in your applications by adding the import keyword:")
|
27 |
+
st.markdown("[import pandas]")
|
28 |
+
st.markdown("Now Pandas is imported and ready to use.")
|
29 |
+
st.subheader("Pandas as pd")
|
30 |
+
st.markdown("Pandas is usually imported under the pd alias.")
|
31 |
+
st.markdown("it is an alternate name of pandas")
|
32 |
+
st.markdown("instead of writing pandas we write pd")
|
33 |
+
st.subheader("Create an alias with the as keyword while importing:")
|
34 |
+
st.markdown("import pandas as pd")
|
35 |
+
st.markdown("Now the Pandas package can be referred to as pd instead of pandas.")
|
36 |
+
st.header("Pandas Series")
|
37 |
+
st.subheader("What is a Series?")
|
38 |
+
st.markdown("A Pandas Series is like a column in a table.")
|
39 |
+
st.markdown("It is a one-dimensional array holding data of any type.")
|
40 |
+
st.subheader("Example:")
|
41 |
+
st.markdown("Create a simple Pandas Series from a list:")
|
42 |
+
st.markdown("import pandas as pd")
|
43 |
+
st.markdown("a = [1, 7, 2]")
|
44 |
+
st.markdown("myvar = pd.Series(a)")
|
45 |
+
st.markdown("print(myvar)")
|
46 |
+
st.subheader("Output:")
|
47 |
+
st.markdown("0 , 1")
|
48 |
+
st.markdown("1 , 7")
|
49 |
+
st.markdown("2 , 2")
|
50 |
+
st.markdown("dtype: int64")
|
51 |
+
st.subheader("Labels:")
|
52 |
+
st.markdown("If nothing else is specified, the values are labeled with their index number. First value has index 0, second value has index 1 etc.")
|
53 |
+
st.markdown("This label can be used to access a specified value.")
|
54 |
+
st.subheader("Example:")
|
55 |
+
st.markdown("Return the first value of the Series:")
|
56 |
+
st.markdown("import pandas as pd")
|
57 |
+
st.markdown("a = [1, 7, 2]")
|
58 |
+
st.markdown("myvar = pd.Series(a)")
|
59 |
+
st.markdown("print(myvar[0])")
|
60 |
+
st.subheader("Output")
|
61 |
+
st.subheader("1")
|
62 |
+
st.subheader("Create Labels:")
|
63 |
+
st.markdown("with the index argument, you can name your own labels.")
|
64 |
+
st.subheader("Example:")
|
65 |
+
st.markdown("import pandas as pd")
|
66 |
+
st.markdown("a = [1, 7, 2]")
|
67 |
+
st.markdown("myvar = pd.Series a, index = [x, y, z]")
|
68 |
+
st.markdown("print(myvar)")
|
69 |
+
st.subheader("Output:")
|
70 |
+
st.markdown("x , 1")
|
71 |
+
st.markdown("y , 7")
|
72 |
+
st.markdown("z , 2")
|
73 |
+
st.markdown("dtype: int64")
|
74 |
+
st.markdown("When you have created labels, you can access an item by referring to the label.")
|
75 |
+
st.subheader("Example:")
|
76 |
+
st.markdown("Return the value of y:")
|
77 |
+
st.subheader("import pandas as pd")
|
78 |
+
st.markdown("a = [1, 7, 2]")
|
79 |
+
st.markdown("myvar = pd.Series(a, index = [x, y, z])")
|
80 |
+
st.markdown("print(myvar [y])")
|
81 |
+
st.subheader("Output:")
|
82 |
+
st.subheader("7")
|
83 |
+
st.subheader("Key/Value Objects as Series")
|
84 |
+
st.markdown("You can also use a key/value object, like a dictionary, when creating a Series.")
|
85 |
+
st.subheader("Example:")
|
86 |
+
st.markdown("Create a simple Pandas Series from a dictionary:")
|
87 |
+
st.markdown("import pandas as pd")
|
88 |
+
st.markdown("calories = day1 : 420, day2 : 380, day3 : 390")
|
89 |
+
st.markdown("myvar = pd.Series(calories)")
|
90 |
+
st.markdown("print(myvar)")
|
91 |
+
st.subheader("Output:")
|
92 |
+
st.markdown("day1 420")
|
93 |
+
st.markdown("day2 380")
|
94 |
+
st.markdown("day3 390")
|
95 |
+
st.markdown("dtype: int64")
|
96 |
+
st.markdown("Note: The keys of the dictionary become the labels.")
|
97 |
+
st.markdown("To select only some of the items in the dictionary, use the index argument and specify only the items you want to include in the Series.")
|
98 |
+
st.subheader("Example:")
|
99 |
+
st.markdown("import pandas as pd")
|
100 |
+
st.markdown("calories = day1 : 420, day2 : 380, day3 : 390")
|
101 |
+
st.markdown("myvar = pd.Series(calories, index = [day1, day2])")
|
102 |
+
st.markdown("print(myvar)")
|
103 |
+
st.subheader("Output:")
|
104 |
+
st.markdown("day1 , 420")
|
105 |
+
st.markdown("day2 , 380")
|
106 |
+
st.markdown("dtype: int64")
|
107 |
+
st.subheader("DataFrames:")
|
108 |
+
st.markdown("Data sets in Pandas are usually multi-dimensional tables, called DataFrames.")
|
109 |
+
st.markdown("Series is like a column, a DataFrame is the whole table.")
|
110 |
+
st.subheader("Example:")
|
111 |
+
st.markdown("Create a DataFrame from two Series:")
|
112 |
+
st.markdown("import pandas as pd")
|
113 |
+
st.markdown("data = {")
|
114 |
+
st.markdown("calories : [420, 380, 390],")
|
115 |
+
st.markdown("duration: [50, 40, 45]")
|
116 |
+
st.markdown("}")
|
117 |
+
st.markdown("myvar = pd.DataFrame(data)")
|
118 |
+
st.markdown("print(myvar)")
|
119 |
+
st.subheader("Output:")
|
120 |
+
st.markdown("calories duration")
|
121 |
+
st.markdown("0 , 420 , 50")
|
122 |
+
st.markdown("1 , 380 , 40")
|
123 |
+
st.markdown("2 , 390 , 45")
|