xxxxxxxxxx
# This function doubles the input value
def double(x):
return 2*x
# Apply this function to double every value in a specified column
df.column1 = df.column1.apply(double)
# Lambda functions can also be supplied to `apply()`
df.column2 = df.column2.apply(lambda x : 3*x)
# Applying to a row requires it to be called on the entire DataFrame
df['newColumn'] = df.apply(lambda row:
row['column1'] * 1.5 + row['column2'],
axis=1
)
xxxxxxxxxx
# to Add a lambda function which will increase the entry in each column by 3
df["column_name"] = df["column_name"].apply(lambda x:x+3)
Eg: df["MPG_City"] = df["MPG_City"].apply(lambda x: x+3)
xxxxxxxxxx
import pandas as pd
s = pd.Series([1,2,3,4,5])
# adding 5 to each value
new = s.apply(lambda num : num + 5)
# printing elements of old and new series
print(s.head().values,"\n",new.head().values)
# [1 2 3 4 5]
# [6 7 8 9 10]
xxxxxxxxxx
df = pd.DataFrame([[4, 9]] * 3, columns=['A', 'B'])
df.apply(np.sqrt)
# A B
#0 2.0 3.0
#1 2.0 3.0
#2 2.0 3.0
xxxxxxxxxx
Method 1: Using the Command Line
Open a terminal and run the following command:
php -v
This will display the PHP version installed on your system.
Method 2: Using the phpinfo() Function
Create a new PHP file (e.g., phpinfo.php) with the following content:
<?php
phpinfo();
?>
Save the file and upload it to your web server (e.g., /var/www/html/).
Open a web browser and navigate to http://localhost/phpinfo.php. This will display a page with information about your PHP installation, including the version.
Method 3: Using the dpkg Command
Open a terminal and run the following command:
dpkg -l | grep php
This will display a list of installed PHP packages, including the version.
Method 4: Using the apt Command
Open a terminal and run the following command:
apt show php
This will display information about the PHP package, including the version.
These methods will help you determine the PHP version installed on your Parrot OS system.
xxxxxxxxxx
import pandas as pd
# Function to add
def add_values(row):
return row['A'] + row['B'] + row['C']
def main():
# Create a dictionary with three fields each
data = {
'A': [1, 2, 3],
'B': [4, 5, 6],
'C': [7, 8, 9]}
# Convert the dictionary into DataFrame
df = pd.DataFrame(data)
print("Original DataFrame:\n", df)
# Apply the user-defined function to every row
df['add'] = df.apply(add_values, axis=1)
print('\nAfter Applying Function: ')
# Print the new DataFrame
print(df)
if __name__ == '__main__':
main()