1 100 QandA of pandas
1.1 how to create a df from a dict
In [35]: dict(x = [1,2,3], y=[4,5,6], z=[True,True,False])
Out[85]: {'x': [1, 2, 3], 'y': [4, 5, 6], 'z': [True, True, False]}
In [86]: import pandas as pd
In [90]: pd.DataFrame(dict(x = [1,2,3], y=[4,5,6], z=[True,True,False]))
Out[102]:
x y z
0 1 4 True
1 2 5 True
2 3 6 False
1.2 how to conver .xls to .csv in pandas
pd.read_excel([filename],[ith_sheet], index_col=None)
---> datafram
-----.to_csv([filename],encoding, index=False)
---> dataframe
import pandas as pd
data_xls = pd.read_excel('excelfile.xlsx', 'Sheet2', index_col=None)
data_xls.to_csv('csvfile.csv', encoding='utf-8', index=False)
1.3 how to read .xls or .csv
import pandas as pd
csv_df = pd.read_csv('filepath')
xsl_df = pd.read_excel('filepath', 'sheetname')
1.4 4 new time-saving tricks in pandas
1.5 how do I apply a function to a pandas Series or DataFrame
1.6 how do I apply multiple filter criteria to a pandas DataFrame
1.7 how do I avoid a SettingWithCopyWarning in pandas
1.8 how do I change display options in pandas
1.9 how do I change the data type of a pandas Series
1.10 how do I create a pandas DataFrame from another object
1.11 how do I create dummy variables in pandas
1.12 how do I explore a pandas Series
1.13 how do I filter rows of panda DataFrame by column value
1.14 how do I find and remove duplicate rows in pandas
1.15 how do I handle missing values in pandas
1.16 how do I make my pandas DataFrame smaller and faster
1.17 how do I read a tabular data file into pandas
1.18 how do I remove columns from a pandas DataFrame
1.19 how do I rename columns in a pandas DataFrame
1.20 how do I select a pandas Series from a DataFrame
1.21 how do I select multiple rows and columns from a pandas DataFrame
1.22 how do I sort a pandas DataFrame or a Series
1.23 how do I use pandas with scikit-learn to create Kaggle submissions
1.24 how do I use string methods in pandas
1.25 how do I use the axis parameter in pandas
1.26 how do I work with dates and times in pandas
1.27 more of your pandas questions answered
1.28 what do I need to know about the pandas index
1.29 what do I need to know about the pandas index
1.30 what is your favorite pandas tricks
1.31 when should I use a groupby in pandas
1.32 when should I use the inplace parameter in pandas
1.33 why do some pandas commands end with parentheses
1.34 your pandas questions answered