import pandas as pd s1= pd.Series([2,3,4,5,6,7,8,9]) print(s1)
0 2 1 3 2 4 3 5 4 6 5 7 6 8 7 9 dtype: int64
import matplotlib.pyplot as plt x=[1,2,3,4] y=[5,10,15,20] plt.bar(x,y,color="red",edgecolor="black") plt.show()
import pandas as pd sh= {"name":["akash","suraj","nitesh","qman","suresh","mike","anuv"], "grade":["A","B","C","D","A","E","B"] ,"subject":["acc","bst","eng","maths","social","hindi","acc"], "id":[2,3,4,5,6,7,1],"year":[2018,2019,2018,2017,2015,2020,2017] } dh=pd.DataFrame(sh) print(dh)
name grade subject id year 0 akash A acc 2 2018 1 suraj B bst 3 2019 2 nitesh C eng 4 2018 3 qman D maths 5 2017 4 suresh A social 6 2015 5 mike E hindi 7 2020 6 anuv B acc 1 2017
import pandas as pd sh= {"name":["akash","suraj","nitesh","qman","suresh","mike","anuv"], "grade":["A","B","C","D","A","E","B"] ,"subject":["acc","bst","eng","maths","social","hindi","acc"], "id":[2,3,4,5,6,7,1],"year":[2018,2019,2018,2017,2015,2020,2017] } dh=pd.DataFrame(sh) dh.subject[2]= "aandbhat" del dh.drop[4] print(dh)
script.py:8: FutureWarning: ChainedAssignmentError: behaviour will change in pandas 3.0! You are setting values through chained assignment. Currently this works in certain cases, but when using Copy-on-Write (which will become the default behaviour in pandas 3.0) this will never work to update the original DataFrame or Series, because the intermediate object on which we are setting values will behave as a copy. A typical example is when you are setting values in a column of a DataFrame, like: df["col"][row_indexer] = value Use `df.loc[row_indexer, "col"] = values` instead, to perform the assignment in a single step and ensure this keeps updating the original `df`. See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dh.subject[2]= "aandbhat" script.py:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dh.subject[2]= "aandbhat" line 9, in <module> del dh.drop[4] ~~~~~~~^^^ TypeError: 'method' object does not support item deletion
import pandas as pd x= [2,3,4,5,] ak= pd.DataFrame(x) z=[4,5,7,8] ka=pd.DataFrame(z) a=ak.append(ka) y=pd.DataFrame(a) print(y)
line 6, in <module> a=ak.append(ka) ^^^^^^^^^ File "/lib/python3.12/site-packages/pandas/core/generic.py", line 6293, in __getattr__ return object.__getattribute__(self, name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'DataFrame' object has no attribute 'append'. Did you mean: '_append'?