pandas_merged
pandas_merged
Import convention
>>> import pandas as pd >>> df.rename(columns={'age':'Age'}) >>> p_df.append(
- Renames the column names >>> df.replace(to_replace=[51, 69.3], value = 58) {'name':'Jim lake',
- Replaces values ‘51, 69.3’ to 58 in the whole dataframe’. 'first':'Jim',
>>> df.columns Column labels >>> df.iloc[[0, 1]] Group of rows and columns by indices.
>>> df.dtypes Datatypes of columns >>> filter = df['name'].str.contains('Rah') Series resulting from the provided string query expression.
>>>df.at[1,'weight'] Single value for a row-column label pair.
>>> df[filter]
>>>df.describe Summary statistics
Display Options Grouping and Aggregation Cleaning Data
>>> pd.set_option('display.max_rows', n)
Handling Missing Values Changing Datatypes
- Sets the max visible rows for dataframe. >>> df.groupby(by=['age', 'name'])
>>> nan_df = pd.DataFrame({ "A" :[1.0, -3.0, 1.0],
- Returns Groupby object grouped by values in given "B" : [1.0, np.nan, 1.0], >>> df['weight'].astype('int64')
>>> pd.reset_option('display') - Converts 'weight' column into integer.
columns. "C" : [3.0, -2.0, 3.0],
- Resets all the display options.
"D" :[1.0, -3.0, 1.0])}
>>> df['name'].value_counts() >>> nan_df.isna() >>> df.astype('string')
- Counts the number of times each value is repeated. - Returns a boolean same-sized object indicating if the values are NA. - Converts every element in the df to string.